Skip to content

Commit 7b73ad2

Browse files
build: add black 25.1.0 and adopt targeted readability formatting
1 parent f7d4027 commit 7b73ad2

4 files changed

Lines changed: 47 additions & 37 deletions

File tree

conftest.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66

77

88
def pytest_addoption(parser):
9-
""" Pytest option variables"""
10-
parser.addoption('--browser',
11-
help=u'Which test browser?',
12-
choices=['chrome', 'firefox'],
13-
default='chrome')
14-
parser.addoption('--remote',
15-
help=u'Is remote webdriver?',
16-
default='')
9+
"""Pytest option variables"""
10+
parser.addoption(
11+
'--browser',
12+
help=u'Which test browser?',
13+
choices=['chrome', 'firefox'],
14+
default='chrome',
15+
)
16+
parser.addoption('--remote', help=u'Is remote webdriver?', default='')
1717

1818

1919
@pytest.fixture(scope='session')
2020
def t_browser(request):
21-
""" Test browser. Params: [chrome, opera, firefox]. """
21+
"""Test browser. Params: [chrome, opera, firefox]."""
2222
return request.config.getoption('--browser')
2323

2424

@@ -30,20 +30,20 @@ def is_remote(request):
3030

3131
@pytest.hookimpl(hookwrapper=True)
3232
def pytest_runtest_setup():
33-
""" Allure hook """
33+
"""Allure hook"""
3434
with AllureCatchLogs():
3535
yield
3636

3737

3838
@pytest.hookimpl(hookwrapper=True)
3939
def pytest_runtest_call():
40-
""" Allure hook """
40+
"""Allure hook"""
4141
with AllureCatchLogs():
4242
yield
4343

4444

4545
@pytest.hookimpl(hookwrapper=True)
4646
def pytest_runtest_teardown():
47-
""" Allure hook """
47+
"""Allure hook"""
4848
with AllureCatchLogs():
4949
yield

fixtures_browsers.py

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,28 +38,30 @@ def choose_driver(is_remote, t_browser):
3838

3939

4040
def custom_driver(t_browser):
41-
""" Custom driver """
41+
"""Custom driver"""
4242
logging.debug('custom driver config start')
4343
if t_browser == 'chrome':
4444
driver = webdriver.Chrome(
4545
service=ChromeService(ChromeDriverManager().install()),
46-
options=headless_chrome_options()
46+
options=headless_chrome_options(),
4747
)
4848
else:
4949
raise ValueError('t_browser does not set')
5050
driver.set_page_load_timeout(10)
51-
browser = Browser(Config(
52-
driver=driver,
53-
timeout=10,
54-
window_width=1366,
55-
window_height=1200,
56-
))
51+
browser = Browser(
52+
Config(
53+
driver=driver,
54+
timeout=10,
55+
window_width=1366,
56+
window_height=1200,
57+
)
58+
)
5759
logging.debug('custom driver config finish')
5860
return browser
5961

6062

6163
def headless_chrome_options():
62-
""" Custom chrome options """
64+
"""Custom chrome options"""
6365
logging.info('set chromedriver options start')
6466
chrome_options = Options()
6567
chrome_options.set_capability("pageLoadStrategy", "eager")
@@ -77,30 +79,34 @@ def headless_chrome_options():
7779

7880

7981
def remote_driver(t_browser, page_load_strategy=None):
80-
""" Remote driver """
82+
"""Remote driver"""
8183
logging.debug('remote driver config start')
8284
remote_mapping = {
8385
'chrome': {
8486
'command_executor': 'http://selenium__standalone-chrome:4444/wd/hub',
85-
'options': webdriver.ChromeOptions()
87+
'options': webdriver.ChromeOptions(),
8688
},
8789
'firefox': {
8890
'command_executor': 'http://selenium__standalone-firefox:4444/wd/hub',
89-
'options': webdriver.FirefoxOptions()
90-
}
91+
'options': webdriver.FirefoxOptions(),
92+
},
9193
}
9294
if page_load_strategy:
9395
desired_capabilities = webdriver.DesiredCapabilities().CHROME
9496
desired_capabilities["pageLoadStrategy"] = "eager"
9597

96-
driver = webdriver.Remote(command_executor=remote_mapping[t_browser]['command_executor'],
97-
options=remote_mapping[t_browser]['options'])
98+
driver = webdriver.Remote(
99+
command_executor=remote_mapping[t_browser]['command_executor'],
100+
options=remote_mapping[t_browser]['options'],
101+
)
98102
driver.set_page_load_timeout(20)
99-
browser = Browser(Config(
100-
driver=driver,
101-
timeout=10,
102-
window_width=1500,
103-
window_height=1200,
104-
))
103+
browser = Browser(
104+
Config(
105+
driver=driver,
106+
timeout=10,
107+
window_width=1500,
108+
window_height=1200,
109+
)
110+
)
105111
logging.debug('remote driver config finish')
106112
return browser

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ pytest-voluptuous==1.2.0
1414
curlify==2.2.1
1515
webdriver-manager==4.0.2
1616
mimesis==18.0.0
17+
black==25.1.0

src/test/test_api.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
from src.test.api_helpers import validate_json_schema
55

66

7-
@mark.parametrize('method, path, schema', [
8-
('GET', '/get', 'get.json'),
9-
('PATCH', '/patch', 'patch.json'),
10-
])
7+
@mark.parametrize(
8+
'method, path, schema',
9+
[
10+
('GET', '/get', 'get.json'),
11+
('PATCH', '/patch', 'patch.json'),
12+
],
13+
)
1114
@allure.title('HTTPBIN {method} "{path}" matches schema "{schema}"')
1215
def test_httpbin_contract(method, path, schema, httpbin):
1316
response = httpbin.request(method=method, url=path)

0 commit comments

Comments
 (0)