-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
56 lines (44 loc) · 1.56 KB
/
conftest.py
File metadata and controls
56 lines (44 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import pytest
import logging
from _pytest.runner import CallInfo
from framework.driver import Driver
from pages.ui_page import UiPage
from api.api import Api
@pytest.fixture(scope="session", autouse=True)
def browser():
""" Запустить браузер перед запуском тестов
и закрыть его по окончании тестов
"""
driver = Driver().connect()
driver.fullscreen_window()
yield
driver.quit()
@pytest.fixture(scope='class', autouse=False)
def finally_clear_subscriptions():
pass
yield
# Проверим, что за бардак там создаётся если приходят некорректные данные
status_code, json_data = Api.get_subscriptions()
assert status_code == 200
print(str(json_data))
logging.info(str(json_data))
status_code, data = Api.clear_subscriptions()
if status_code == 200:
logging.info(f'База подписок ощищена! Удалено {data["removed"]} записей.')
else:
raise RuntimeError('Не удалось очистить базу подписок!')
@pytest.fixture(scope='class', autouse=False)
def suite_data():
print("General suite setup")
yield
print("General suite teardown")
@pytest.fixture(scope='module', autouse=True)
def open_ui_page():
ui_page = UiPage()
ui_page.open()
yield
pass
def pytest_exception_interact(node, call: CallInfo, report):
logger = logging.getLogger(__name__)
if report.failed:
logger.error(call.excinfo)