ТЭ
Size: a a a
СС
ТЭ
ТЭ
ТЭ
СС
СС
СС
СС
HS
OC
def pytest_addoption(parser):
parser.addoption("--uuid", action="store", dest="uuid")
@pytest.fixture
def uuid_opt(request):
return request.config.getoption("uuid")
@pytest.hookimpl(hookwrapper=True, tryfirst=True)
def pytest_runtest_makereport(item, call):
....
outcome = yield
rep = outcome.get_result()
...
return ''
OC
_pytest.config.Config
объект, поэтому можно прямо так обратиться:@pytest.hookimpl(hookwrapper=True, tryfirst=True)Задачу это решает, не знаю ок или не ок, если вы вне хуков, наверное лучше обойтись фикстурой
def pytest_runtest_makereport(item, call):
....
outcome = yield
rep = outcome.get_result()
item.config.getoption("uuid")
...
return ''
ДЛ
data = {
"name": "some subscription",
"planned_period": {
"is_paid": True,
"start_at": datetime.datetime.now()
}
}
if name is not None:
data.update({"name": name})
data = {
"planned_period": {
"is_paid": True,
"start_at": datetime.datetime.now()
}
}
if is_paid is not None:
data.update({
"planned_period": {
"is_paid": is_paid
}
})
if start_at is not None:
data.update({
"planned_period": {
"start_at": start_at
}
})
В
ДЛ
data = {
"name": name,
"planned period": {}
}
ИС
pydantic
.В
data = {
"name": name
}
V
from collections import defaultdict
data = defaultdict(dict)
if is_paid is not None:
data['planned_period']["is_paid"] = is_paid
if start_at is not None:
data['planned_period']["start_at"] = start_at
data = dict(data)
ДЛ
EK