--dist=loadscope: tests will be grouped by module for test functions and by class for test methods, then each group will be sent to an available worker, guaranteeing that all tests in a group run in the same process. This can be useful if you have expensive module-level or class-level fixtures. Currently the groupings can’t be customized, with grouping by class takes priority over grouping by module. This feature was added in version 1.19.
--dist=loadfile: tests will be grouped by file name, and then will be sent to an available worker, guaranteeing that all tests in a group run in the same worker. This feature was added in version 1.21.
from datetime import datetime, timedelta
from random import randint
t = datetime.now().replace(minute=0, second=0, microsecond=0)
list_event = [(t + timedelta(minutes=30 * i)).time().isoformat() for i in range(48)]
values = [randint(1, 100) for _ in range(48)]
records = [dict(zip(('time', 'value'), value)) for value in zip(list_event, values)]
from collections import namedtuple
Hint = namedtuple('Hint', ('title', 'event', 'used'))
hints = {
'1': Hint('Помощь зала', lambda: None, 0),
'2': Hint('50/50а', lambda: None, 0),
'3': Hint('Звонок другу', lambda: None, 0)
}
current_hints = hints.copy()
print('Текущии подсказки:\n', hints)
need_help = input("Вам нужна помощь?\n1.Да\n2.Нет\n ")
if need_help == "1":
what_help = input({key: hint.title for key, hint in hints.items() if not hint.used})
tip = current_hints[what_help]
tip.event()
current_hints[what_help] = tip._replace(used=True)
print('Текущии подсказки:\n', [hint.title for hint in current_hints.values() if not hint.used])
from itertools import groupby
source = [
{'code': 'AA01', 'group': 'U01', 'user': '1375', },
{'code': 'AA01', 'group': 'U01', 'user': '1575', },
{'code': 'AA03', 'group': 'U02', 'user': '1375', },
{'code': 'AA02', 'group': 'U02', 'user': '1345', },
{'code': 'AA02', 'group': 'U03', 'user': '1315', },
{'code': 'AA01', 'group': 'U04', 'user': '1615', },
]
result = {k:list(v) for k,v in groupby(source, lambda x: x['group'])}
>>> print(result)
{'U01': [{'code': 'AA01', 'group': 'U01', 'user': '1375'}, {'code': 'AA01', 'group': 'U01', 'user': '1575'}], 'U02': [{'code': 'AA03', 'group': 'U02', 'user': '1375'}, {'code': 'AA02', 'group': 'U02', 'user': '1345'}], 'U03': [{'code': 'AA02', 'group': 'U03', 'user': '1315'}], 'U04': [{'code': 'AA01', 'group': 'U04', 'user': '1615'}]}
>>> result = {k:{row['user']: row['code'] for row in v} for k,v in groupby(source, lambda x: x['group'])}
>>> result
{'U01': {'1375': 'AA01', '1575': 'AA01'}, 'U02': {'1375': 'AA03', '1345': 'AA02'}, 'U03': {'1315': 'AA02'}, 'U04': {'1615': 'AA01'}}
>>>
s = [23,45,67]
from itertools import chain, combinations
def all_subsets(ss):
return chain(*map(lambda x: combinations(ss, x), range(1, len(ss)+1)))
variants = max([vv for vv in (sum(v) for v in all_subsets(s)) if vv % 2 == 0])
d ={'BTC': [(None, None), (1, -0.4), (3, 0.3333333333333333), (0, 0.75), (1, None)], 'ETH': [(None, None), (0, 0.5), (0, 0.3333333333333333), (0, -0.1), (2, None)]}
[dict(zip(d.keys(), v)) for v in zip(*d.values())]
[{'BTC': (None, None), 'ETH': (None, None)},
{'BTC': (1, -0.4), 'ETH': (0, 0.5)},
{'BTC': (3, 0.3333333333333333), 'ETH': (0, 0.3333333333333333)},
{'BTC': (0, 0.75), 'ETH': (0, -0.1)},
{'BTC': (1, None), 'ETH': (2, None)}]
import re
s = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
words = re.sub("[^\w]", " ", s).split()
# если просто найти все минимальные слова
t = [v for v in words if len(v) == len(min(words))]
# если все слова надо разделить по длине
from itertools import groupby
t1 = {k:list(v) for k,v in groupby(sorted(words, key=len), len)}
print(t1[min(t1)], t)
test.py:
from selenium import webdriver
driver = webdriver.Chrome()
test1.py:
from test import driver