Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
КОНФИГИ ВМЕСТО КОСТЫЛЕЙ
PYTESTCONFIG И ЗАЧЕМ ОН НУЖЕН
КТО ТАКАЯ Я
• Юля
• 5+ лет в ручном тестировании,
• 2 года в автоматизации (Java, NodeJS, Python)
• Тестировала веб, десктоп и мобилки в
стартапах и интеграторах
• А сейчас - Ламода
ЧТО ТАКОЕ LAMODA
~ 11 млн. покупателей
Бесконечно длинный, больше 60
штук, список проектов Ламоды,
среди которых скромно так
затесался мой горячо любимый
AB-testing API, а остальные
сегодня не особо-то важны
WE CODE THE FASHION
± 300 сотрудников в IT
ЧТО ТАКОЕ LAMODA
~ 11 млн. покупателей
Бесконечно длинный, больше 60
штук, список проектов Ламоды,
среди которых скромно так
затесался мой горячо любимый
AB-testing API, а остальные
сегодня не особо-то важны
WE CODE THE FASHION
± 250 сотрудников в IT
ЧТО ТАКОЕ LAMODA
~ 11 млн. покупателей
Бесконечно длинный, больше 60
штук, список проектов Ламоды,
среди которых скромно так
затесался мой горячо любимый
AB-testing API, а остальные
сегодня не особо-то важны
WE CODE THE FASHION
± 250 сотрудников в IT
AB-testingAPI
DB
AB-testingAPI
DB
PROD QA
AB-testingAPI
DB
AB-testingAPI
DB
PROD QA
AB-testingAPI
DB
AB-testingAPI
DB
AB-testingAPI
PROD QA
PREPROD
AB-testingAPI
DB
AB-testingAPI
PROD
PREPROD
request
response1
AB-testingAPI
DB
AB-testingAPI
PROD
PREPROD
request
request
response1
response2
ЗАДАЧА
• Надёжные
• Простые
• Безопасные
Добавить регрессионные тесты на препроде
ВАРИАНТЫ РЕШЕНИЯ
ВАРИАНТЫ РЕШЕНИЯ
1. Отдельный проект
ВАРИАНТЫ РЕШЕНИЯ
1. Отдельный проект
a. Это просто
b. Это безопасно
ВАРИАНТЫ РЕШЕНИЯ
1. Отдельный проект
a. Это просто
b. Это безопасно
c. Это лень
ВАРИАНТЫ РЕШЕНИЯ
1. Отдельный проект
a. Это просто
b. Это безопасно
c. Это лень
ВАРИАНТЫ РЕШЕНИЯ
1. Отдельный проект
a. Это просто
b. Это безопасно
c. Это лень
2. Allure @allure.severity(pytest.allure.severity_level.CRITICAL)
#terminal
>>pytest rnd.tests/ --allure_severities=critical
ВАРИАНТЫ РЕШЕНИЯ
1. Отдельный проект
a. Это просто
b. Это безопасно
c. Это лень
2. Allure
a. Это просто
b. Это безопасно @allure.severity(pytest.allure.severity_level.CRITICAL)
#terminal
>>pytest rnd.tests/ --allure_severities=critical
ВАРИАНТЫ РЕШЕНИЯ
@allure.severity(pytest.allure.severity_level.CRITICAL)
1. Отдельный проект
a. Это просто
b. Это безопасно
c. Это лень
2. Allure
a. Это просто
b. Это безопасно (не очень)
#terminal
>>pytest rnd.tests/ --allure_severities=critical
ВАРИАНТЫ РЕШЕНИЯ
1. Отдельный проект
a. Это просто
b. Это безопасно
c. Это лень
2. Allure
a. Это просто
b. Это безопасно (не очень)
c. Это тоже лень
@allure.severity(pytest.allure.severity_level.CRITICAL)
#terminal
>>pytest rnd.tests/ --allure_severities=critical
ВАРИАНТЫ РЕШЕНИЯ
1. Отдельный проект
a. Это просто
b. Это безопасно
c. Это лень
2. Allure
a. Это просто
b. Это безопасно (не очень)
c. Это тоже лень
ВАРИАНТЫ РЕШЕНИЯ
1. Отдельный проект
a. Это просто
b. Это безопасно
c. Это лень
2. Allure
a. Это просто
b. Это безопасно (не очень)
c. Это тоже лень
3. Pytest config
ВАРИАНТЫ РЕШЕНИЯ
1. Отдельный проект
a. Это просто
b. Это безопасно
c. Это лень
2. Allure
a. Это просто
b. Это безопасно (не очень)
c. Это тоже лень
3. Pytest config
a. Это просто
b. Это безопасно
c. Это действительно просто
>> pytest rnd.tests/
В ИДЕАЛЬНОМ МИРЕ
>> pytest rnd.tests/ --environment = preprod
В ИДЕАЛЬНОМ МИРЕ
>> pytest rnd.tests/ --environment = preprod[ ]
В ИДЕАЛЬНОМ МИРЕ
>> pytest rnd.tests/ --environment = preprod[ ]
URLs set Tests set
В ИДЕАЛЬНОМ МИРЕ
КАК РАБОТАЕТ PYTEST
>> pytest rnd.tests/ --environment = preprod
КАК РАБОТАЕТ PYTEST
1. Configuration
>> pytest rnd.tests/ --environment = preprod
КАК РАБОТАЕТ PYTEST
1. Configuration
>> pytest rnd.tests/ --environment = preprod
1) строка запуска
КАК РАБОТАЕТ PYTEST
1. Configuration
>> pytest rnd.tests/ --environment = preprod
1) строка запуска
КАК РАБОТАЕТ PYTEST
1. Configuration
>> pytest rnd.tests/ --environment = preprod
1) строка запуска
2) conftest.py
КАК РАБОТАЕТ PYTEST
1. Configuration
>> pytest rnd.tests/ --environment = preprod
1) строка запуска
2) conftest.py
3) строка запуска ещё раз
КАК РАБОТАЕТ PYTEST
1. Configuration
2. Collection
>> pytest rnd.tests/ --environment = preprod
КАК РАБОТАЕТ PYTEST
1. Configuration
2. Collection
3. Running
>> pytest rnd.tests/ --environment = preprod
1) фикстуры
КАК РАБОТАЕТ PYTEST
1. Configuration
2. Collection
3. Running
>> pytest rnd.tests/ --environment = preprod
1) фикстуры
2) тесты
КАК РАБОТАЕТ PYTEST
1. Configuration
2. Collection
3. Running
>> pytest rnd.tests/ --environment = preprod
1) фикстуры
2) тесты
3) очистка
КАК РАБОТАЕТ PYTEST
1. Configuration
2. Collection
3. Running
4. Reporting
>> pytest rnd.tests/ --environment = preprod
КАК РАБОТАЕТ PYTEST
1. Configuration
2. Collection
3. Running
4. Reporting
>> pytest rnd.tests/ --environment = preprod
КАК РАБОТАЕТ PYTEST
1. Configuration
2. Collection
3. Running
4. Reporting
>> pytest rnd.tests/ --environment = preprod
ДОБАВЛЯЕМ АРГУМЕНТ
#	content	of	conftest.py
import	pytest
def pytest_addoption(parser):
parser.addoption("--environment",	action="store",	default="qa",
help="target	environment")
ДОБАВЛЯЕМ АРГУМЕНТ
#	content	of	
import	pytest
def pytest_addoption(parser):
parser.addoption("--environment",	action="store",	default="qa",
help="target	environment")
conftest.py
CONFTEST.PY
CONFTEST.PY
project_root
|
|——A
| |——test_1.py
| |——test_2.py
| |——conftest.py
|
|——B
| |——test_2.py
|
|——conftest.py
CONFTEST.PY
1. Фикстуры project_root
|
|——A
| |——test_1.py
| |——test_2.py
| |——conftest.py
|
|——B
| |——test_2.py
|
|——conftest.py
CONFTEST.PY
1. Фикстуры root
|
|——A
| |——test_1.py
| |——test_2.py
| |——conftest.py
|
|——B
| |——test_2.py
|
|——conftest.py
CONFTEST.PY
1. Фикстуры project_root
|
|——A
| |——test_1.py
| |——test_2.py
| |——conftest.py
|
|——B
| |——test_2.py
|
|——conftest.py
CONFTEST.PY
1. Фикстуры
2. Хуки
3. Плагины
project_root
|
|——A
| |——test_1.py
| |——test_2.py
| |——conftest.py
|
|——B
| |——test_2.py
|
|——conftest.py
ДОБАВЛЯЕМ АРГУМЕНТ
#	content	of	
import	pytest
def pytest_addoption(parser):
parser.addoption("--environment",	action="store",	default="qa",
help="target	environment")
conftest.py
ДОБАВЛЯЕМ АРГУМЕНТ
#	content	of	conftest.py
import	pytest
def pytest_addoption(parser):
parser.addoption("--environment",	action="store",	default="qa",
help="target	environment")
ДОБАВЛЯЕМ АРГУМЕНТ
#	content	of	conftest.py
import	pytest
def pytest_addoption(parser):
parser.addoption("--environment",	action="store",	default="qa",
help="target	environment")
ДОБАВЛЯЕМ АРГУМЕНТ
#	content	of	conftest.py
import	pytest
def pytest_addoption(parser):
parser.addoption("--environment",	action="store",	default="qa",
help="target	environment")
В ИДЕАЛЬНОМ МИРЕ
>> pytest rnd.tests/ --environment = preprod[ ]
URLs set Tests set
В ИДЕАЛЬНОМ МИРЕ
>> pytest rnd.tests/ --environment = preprod[ ]
URLs set Tests set
КАК РАБОТАЕТ PYTEST
1. Configuration
2. Collection
3. Running
4. Reporting
>> pytest rnd.tests/ --environment = preprod
КАК РАБОТАЕТ PYTEST
1. Configuration
2. Collection
3. Running
4. Reporting
>> pytest rnd.tests/ --environment = preprod
#	content	of	conftest.py
import	pytest
def pytest_addoption(parser):
parser.addoption("--environment",	action="store",	default="qa",
help="target	environment")
#	content	of	conftest.py
import	pytest
def pytest_addoption(parser):
parser.addoption("--environment",	action="store",	default="qa",
help="target	environment")
@pytest.fixture(scope="session")
def env_settings(pytestconfig):
url_set =	'something	impossible'
return	url_set
#	content	of	conftest.py
import	pytest
def pytest_addoption(parser):
parser.addoption("--environment",	action="store",	default="qa",
help="target	environment")
@pytest.fixture(scope="session")
def env_settings(pytestconfig):
url_set =	'something	impossible'
return	url_set
PYTEST.CONFIG
PYTEST.CONFIG
#content	of	try_test.py
def test_view_config(pytestconfig):
print(pytestconfig.option)
assert	False
PYTEST.CONFIG
#output
<CmdOptions {'keyword':	'',	'markexpr':	'',	'maxfail':	0,	'continue_on_collection_errors':	False,	'confcutdir':	
None,	'noconftest':	False,	'keepduplicates':	False,	'basetemp':	None,	'verbose':	0,	'quiet':	0,	'reportchars':	'',	
'disablepytestwarnings':	False,	'showlocals':	False,	'tbstyle':	'auto',	'fulltrace':	False,	'color':	'auto',	
'durations':	None,	'showfixtures':	False,	'show_fixtures_per_test':	False,	'importmode':	'prepend',	'capture':	
'fd',	'runxfail':	False,	'pastebin':	None,	'plugins':	[],	'traceconfig':	False,	'debug':	False,	'assertmode':	
'rewrite',	'xmlpath':	None,	'junitprefix':	None,	'resultlog':	None,	'doctestmodules':	False,	'doctestreport':	
'udiff',	'doctestglob':	[],	'doctest_ignore_import_errors':	False,	'allurereportdir':	None,	'allureseverities':	{},	
'allurefeatures':	{},	'allurestories':	{},	'environment':	'qa',	'markers':	False,	'strict':	False,	'inifilename':	None,	
'usepdb':	False,	'usepdb_cls':	None,	'lf':	False,	'failedfirst':	False,	'cacheshow':	False,	'cacheclear':	False,	
'collectonly':	False,	'pyargs':	False,	'ignore':	None,	'version':	False,	'help':	False,	'override_ini':	None,	
'setuponly':	False,	'setupshow':	False,	'setupplan':	False,	'file_or_dir':	['rnd_tests/tests/try_test.py']}>
#content	of	try_test.py
def test_view_config(pytestconfig):
print(pytestconfig.option)
assert	False
PYTEST.CONFIG
#output
<CmdOptions {'keyword':	'',	'markexpr':	'',	'maxfail':	0,	'continue_on_collection_errors':	False,	'confcutdir':	
None,	'noconftest':	False,	'keepduplicates':	False,	'basetemp':	None,	'verbose':	0,	'quiet':	0,	'reportchars':	'',	
'disablepytestwarnings':	False,	'showlocals':	False,	'tbstyle':	'auto',	'fulltrace':	False,	'color':	'auto',	
'durations':	None,	'showfixtures':	False,	'show_fixtures_per_test':	False,	'importmode':	'prepend',	'capture':	
'fd',	'runxfail':	False,	'pastebin':	None,	'plugins':	[],	'traceconfig':	False,	'debug':	False,	'assertmode':	
'rewrite',	'xmlpath':	None,	'junitprefix':	None,	'resultlog':	None,	'doctestmodules':	False,	'doctestreport':	
'udiff',	'doctestglob':	[],	'doctest_ignore_import_errors':	False,	'allurereportdir':	None,	'allureseverities':	{},	
'allurefeatures':	{},	'allurestories':	{},	'environment':	'qa',	'markers':	False,	'strict':	False,	'inifilename':	None,	
'usepdb':	False,	'usepdb_cls':	None,	'lf':	False,	'failedfirst':	False,	'cacheshow':	False,	'cacheclear':	False,	
'collectonly':	False,	'pyargs':	False,	'ignore':	None,	'version':	False,	'help':	False,	'override_ini':	None,	
'setuponly':	False,	'setupshow':	False,	'setupplan':	False,	'file_or_dir':	['rnd_tests/tests/try_test.py']}>
#content	of	try_test.py
def test_view_config(pytestconfig):
print(pytestconfig.option)
assert	False
#	content	of	conftest.py
import	pytest
def pytest_addoption(parser):
parser.addoption("--environment",	action="store",	default="qa",
help="target	environment")
@pytest.fixture(scope="session")
def env_settings(pytestconfig):
url_set =	'something	impossible'
return	url_set
#	content	of	conftest.py
import	pytest
def pytest_addoption(parser):
parser.addoption("--environment",	action="store",	default="qa",
help="target	environment")
@pytest.fixture(scope="session")
def env_settings(pytestconfig):
url_set =	
return	url_set
#somewhere	else
def get_urls(env):
if	env ==	'preprod':	url =	'http://preprod.lamoda.ru'
else:	url =	'http://qa.lamoda.ru'
return	url
get_urls(pytestconfig.getoption('--environment'))
#	content	of	conftest.py
import	pytest
def pytest_addoption(parser):
parser.addoption("--environment",	action="store",	default="qa",
help="target	environment")
@pytest.fixture(scope="session")
def env_settings(pytestconfig):
url_set =	
return	url_set
#somewhere	else
def get_urls(env):
if	env ==	'preprod':	url =	'http://preprod.lamoda.ru'
else:	url =	'http://qa.lamoda.ru'
return	url
get_urls(pytestconfig.getoption('--environment'))
#	content	of	conftest.py
import	pytest
def pytest_addoption(parser):
parser.addoption("--environment",	action="store",	default="qa",
help="target	environment")
@pytest.fixture(scope="session")
def env_settings(pytestconfig):
url_set =	
return	url_set
#somewhere	else
def get_urls(env):
if	env ==	'preprod':	url =	'http://preprod.lamoda.ru'
else:	url =	'http://qa.lamoda.ru'
return	url
get_urls(pytestconfig.getoption('--environment'))
В ИДЕАЛЬНОМ МИРЕ
>> pytest rnd.tests/ --environment = preprod[ ]
URLs set Tests set
В ИДЕАЛЬНОМ МИРЕ
>> pytest rnd.tests/ --environment = preprod[ ]
URLs set Tests set
КАК РАБОТАЕТ PYTEST
1. Configuration
2. Collection
3. Running
4. Reporting
>> pytest rnd.tests/ --environment = preprod
КАК РАБОТАЕТ PYTEST
1. Configuration
2. Collection
3. Running
4. Reporting
>> pytest rnd.tests/ --environment = preprod
2. COLLECTION
a. skip/skipif #content	of	test_preprod.py
@pytest.mark.skipif(pytest.config.option.environment==	'qa',	
reason	=	'Preprodtest')
def test_preprod(some_fixture):
assert	False
2. COLLECTION
a. skip/skipif #content	of	test_preprod.py
@pytest.mark.skipif(pytest.config.option.environment==	'qa',	
reason	=	'Preprodtest')
def test_preprod(some_fixture):
assert	False
2. COLLECTION
a. skip/skipif #content	of	test_preprod.py
@pytest.mark.skipif(pytest.config.option.environment==	'qa',	
reason	=	'Preprodtest')
def test_preprod(some_fixture):
assert	False
#content	of	test_qa.py
@pytest.mark.skipif(pytest.config.option.environment==	’preprod',	
reason	=	’QA	test')
def test_qa(some_fixture):
assert	False
2. COLLECTION
a. skip/skipif #content	of	test_preprod.py
@pytest.mark.skipif(pytest.config.option.environment==	'qa',	
reason	=	'Preprodtest')
def test_preprod(some_fixture):
assert	False
#content	of	test_qa.py
@pytest.mark.skipif(pytest.config.option.environment==	’preprod',	
reason	=	’QA	test')
def test_qa(some_fixture):
assert	False
2. COLLECTION
a. skip/skipif
b. --m/mark #content	of	test_preprod.py
@pytest.mark.smoke
def test_preprod(some_fixture):
assert	False
#terminal
>>pytest rnd_tests --m	'smoke'
2. COLLECTION
a. skip/skipif
b. --m/mark #content	of	test_preprod.py
@pytest.mark.smoke
def test_preprod(some_fixture):
assert	False
#terminal
>>pytest rnd_tests --m	'smoke'
>>pytest rnd_tests --m	'not	smoke'
2. COLLECTION
a. skip/skipif
b. --m/mark #content	of	test_preprod.py
@pytest.mark.smoke
def test_preprod(some_fixture):
assert	False
#terminal
>>pytest rnd_tests --m	'smoke'
>>pytest rnd_tests --m	'not	smoke'
#content	of	test_preprod.py
@pytest.mark.smoke
def test_preprod(some_fixture):
assert	False
#terminal
>>pytest rnd_tests --m	'smoke'	 --environment	=	'preprod'
#content	of	test_preprod.py
@pytest.mark.smoke
def test_preprod(some_fixture):
assert	False
#terminal
>>pytest rnd_tests --m	'smoke'	 --environment	=	'preprod'
PYTEST.CONFIG
#output
<CmdOptions {'keyword':	'',	'markexpr':	'',	'maxfail':	0,	'continue_on_collection_errors':	False,	'confcutdir':	
None,	'noconftest':	False,	'keepduplicates':	False,	'basetemp':	None,	'verbose':	0,	'quiet':	0,	'reportchars':	'',	
'disablepytestwarnings':	False,	'showlocals':	False,	'tbstyle':	'auto',	'fulltrace':	False,	'color':	'auto',	
'durations':	None,	'showfixtures':	False,	'show_fixtures_per_test':	False,	'importmode':	'prepend',	'capture':	
'fd',	'runxfail':	False,	'pastebin':	None,	'plugins':	[],	'traceconfig':	False,	'debug':	False,	'assertmode':	
'rewrite',	'xmlpath':	None,	'junitprefix':	None,	'resultlog':	None,	'doctestmodules':	False,	'doctestreport':	
'udiff',	'doctestglob':	[],	'doctest_ignore_import_errors':	False,	'allurereportdir':	None,	'allureseverities':	{},	
'allurefeatures':	{},	'allurestories':	{},	'environment':	'qa',	'markers':	False,	'strict':	False,	'inifilename':	None,	
'usepdb':	False,	'usepdb_cls':	None,	'lf':	False,	'failedfirst':	False,	'cacheshow':	False,	'cacheclear':	False,	
'collectonly':	False,	'pyargs':	False,	'ignore':	None,	'version':	False,	'help':	False,	'override_ini':	None,	
'setuponly':	False,	'setupshow':	False,	'setupplan':	False,	'file_or_dir':	['rnd_tests/tests/try_test.py']}>
#content	of	try_test.py
def test_view_config(pytestconfig):
print(pytestconfig.option)
assert	False
PYTEST.CONFIG
#output
<CmdOptions {'keyword':	'',	'markexpr':	'',	'maxfail':	0,	'continue_on_collection_errors':	False,	'confcutdir':	
None,	'noconftest':	False,	'keepduplicates':	False,	'basetemp':	None,	'verbose':	0,	'quiet':	0,	'reportchars':	'',	
'disablepytestwarnings':	False,	'showlocals':	False,	'tbstyle':	'auto',	'fulltrace':	False,	'color':	'auto',	
'durations':	None,	'showfixtures':	False,	'show_fixtures_per_test':	False,	'importmode':	'prepend',	'capture':	
'fd',	'runxfail':	False,	'pastebin':	None,	'plugins':	[],	'traceconfig':	False,	'debug':	False,	'assertmode':	
'rewrite',	'xmlpath':	None,	'junitprefix':	None,	'resultlog':	None,	'doctestmodules':	False,	'doctestreport':	
'udiff',	'doctestglob':	[],	'doctest_ignore_import_errors':	False,	'allurereportdir':	None,	'allureseverities':	{},	
'allurefeatures':	{},	'allurestories':	{},	'environment':	'qa',	'markers':	False,	'strict':	False,	'inifilename':	None,	
'usepdb':	False,	'usepdb_cls':	None,	'lf':	False,	'failedfirst':	False,	'cacheshow':	False,	'cacheclear':	False,	
'collectonly':	False,	'pyargs':	False,	'ignore':	None,	'version':	False,	'help':	False,	'override_ini':	None,	
'setuponly':	False,	'setupshow':	False,	'setupplan':	False,	'file_or_dir':	['rnd_tests/tests/try_test.py']}>
#content	of	try_test.py
def test_view_config(pytestconfig):
print(pytestconfig.option)
assert	False
PYTEST.CONFIG
#content	of	try_test.py
def test_view_config(pytestconfig):
print(pytestconfig.option)
assert	False
#output	with	–m	=	'smoke'
<CmdOptions {'keyword':	'',	'markexpr':	'smoke',	'maxfail':	0,	'continue_on_collection_errors':	False,	
'confcutdir':	None,	'noconftest':	False,	'keepduplicates':	False,	'basetemp':	None,	'verbose':	0,	'quiet':	0,	
'reportchars':	'',	'disablepytestwarnings':	False,	'showlocals':	False,	'tbstyle':	'auto',	'fulltrace':	False,	'color':	
'auto',	'durations':	None,	'showfixtures':	False,	'show_fixtures_per_test':	False,	'importmode':	'prepend',	
'capture':	'fd',	'runxfail':	False,	'pastebin':	None,	'plugins':	[],	'traceconfig':	False,	'debug':	False,	
'assertmode':	'rewrite',	'xmlpath':	None,	'junitprefix':	None,	'resultlog':	None,	'doctestmodules':	False,	
'doctestreport':	'udiff',	'doctestglob':	[],	'doctest_ignore_import_errors':	False,	'allurereportdir':	None,	
'allureseverities':	{},	'allurefeatures':	{},	'allurestories':	{},	'environment':	'qa',	'markers':	False,	'strict':	False,	
'inifilename':	None,	'usepdb':	False,	'usepdb_cls':	None,	'lf':	False,	'failedfirst':	False,	'cacheshow':	False,	
'cacheclear':	False,	'collectonly':	False,	'pyargs':	False,	'ignore':	None,	'version':	False,	'help':	False,	
'override_ini':	None,	'setuponly':	False,	'setupshow':	False,	'setupplan':	False,	'file_or_dir':	
['rnd_tests/tests/try_test.py']}>
КАК РАБОТАЕТ PYTEST
1. Configuration
2. Collection
3. Running
4. Reporting
>> pytest rnd.tests/ --environment = preprod
КАК РАБОТАЕТ PYTEST
1. Configuration
2. Collection
3. Running
4. Reporting
>> pytest rnd.tests/ --environment = preprod
#	content	of	conftest.py
import	pytest
def pytest_addoption(parser):
parser.addoption("--environment",	action="store",	default="qa",
help="target	environment")
@pytest.fixture(scope="session")
def env_settings(pytestconfig):
url_set =	get_urls(pytestconfig.getoption('--environment'))
return	url_set
#somewhere	else
def get_urls(env):
if	env ==	'preprod':	url =	'http://preprod.lamoda.ru'
else:	url =	'http://qa.lamoda.ru'
return	url
def pytest_configure(config):
if	config.option.environment ==	'preprod':
config.option.markexpr =	'smoke'
#	content	of	conftest.py
import	pytest
def pytest_addoption(parser):
parser.addoption("--environment",	action="store",	default="qa",
help="target	environment")
@pytest.fixture(scope="session")
def env_settings(pytestconfig):
url_set =	get_urls(pytestconfig.getoption('--environment'))
return	url_set
#somewhere	else
def get_urls(env):
if	env ==	'preprod':	url =	'http://preprod.lamoda.ru'
else:	url =	'http://qa.lamoda.ru'
return	url
def pytest_configure(config):
if	config.option.environment==	'preprod':
config.option.markexpr =	'smoke'
else:
config.option.markexpr =	'not	smoke'
#	content	of	conftest.py
import	pytest
def pytest_addoption(parser):
parser.addoption("--environment",	action="store",	default="qa",
help="target	environment")
@pytest.fixture(scope="session")
def env_settings(pytestconfig):
url_set =	get_urls(pytestconfig.getoption('--environment'))
return	url_set
#somewhere	else
def get_urls(env):
if	env ==	'preprod':	url =	'http://preprod.lamoda.ru'
else:	url =	'http://qa.lamoda.ru'
return	url
def pytest_configure(config):
if	config.option.environment==	'preprod':
config.option.markexpr =	'smoke'
else:
config.option.markexpr =	'not	smoke'
В ИДЕАЛЬНОМ МИРЕ
>> pytest rnd.tests/
В ИДЕАЛЬНОМ МИРЕ
>> pytest rnd.tests/ --environment = preprod
В ИДЕАЛЬНОМ МИРЕ
1. Настроен раздельный запуск тестов для разных сред
2. Исключены человеческие ошибки при запуске
3. Добавлен минимум кода
4. Добавлено 0 дополнений
В ИДЕАЛЬНОМ МИРЕ
1. Настроен раздельный запуск тестов для разных сред
2. Исключены человеческие ошибки при запуске
3. Добавлен минимум кода
4. Добавлено 0 дополнений
https://docs.pytest.org
tech.lamoda.ru
julia-shpulia
@StickersMM

More Related Content

Конфиги вместо костылей. Pytestconfig и зачем он нужен