-
Notifications
You must be signed in to change notification settings - Fork 1
/
conftest.py
43 lines (32 loc) · 1.58 KB
/
conftest.py
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
import logging
import re
import pytest
pytest.register_assert_rewrite("tests.helpers")
def pytest_collection_modifyitems(items, config):
items[:] = list(filter(should_perform_test, items))
added = []
for item in items:
module_name = item.module.__name__ # type: str
if module_name.startswith("tests.urls"):
domain = module_name.split(".")[-1].removesuffix("_test")
if domain not in added:
config.addinivalue_line("markers", domain)
added += [domain]
item.add_marker(getattr(pytest.mark, domain))
function_name = item.function.__name__ # type: str
if function_name.startswith("test_parsing"):
item.add_marker(pytest.mark.parsing)
item._nodeid = re.sub(r"::test_parsing\[(.*)-(.*)-(.*)\]", "::test_parsing::\\3[\\1]", item.nodeid)
if isinstance(item.parent, pytest.Class):
item._node_id = re.sub(r"::test_", f"{item.parent.__class__.__name__}::test_", item.nodeid)
def should_perform_test(item) -> bool:
for property_name in ["posts", "post_count",
"assets", "asset_count",
"score", "created_at", "gallery",
"redirect_url_properties"]:
if item.name.endswith(f"test_{property_name}") and getattr(item.parent.obj, property_name) is None:
return False
return True
logging.getLogger("PIL").setLevel(logging.INFO)
logging.getLogger("pyrate_limiter").setLevel(logging.INFO)
logging.getLogger("urllib3").setLevel(logging.INFO)