-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathconftest.py
More file actions
46 lines (37 loc) · 1.35 KB
/
conftest.py
File metadata and controls
46 lines (37 loc) · 1.35 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
"""Common utilities for tests
@author: Jesse Schwartzentruber (:truber)
@license:
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
"""
import contextlib
import importlib
import sys
# Currently, the version of django used here is not supported by python 3.12
# Check that django is available before setting the pytest_plugins otherwise the tests
# will fail.
if importlib.util.find_spec("django"):
pytest_plugins = ["covmanager.tests.conftest"]
with contextlib.suppress(ImportError):
import pytest
from django.core.cache import cache
# Cache clearing ensures each test starts with fresh rate limit counters,
# preventing false throttling errors and maintaining test isolation
@pytest.fixture(autouse=True)
def clear_cache():
cache.clear()
yield
cache.clear()
def pytest_ignore_collect(collection_path, config):
# 3.12 not supported yet
if sys.version_info >= (3, 12):
rel_path = collection_path.relative_to(config.rootdir)
if rel_path.parts[0] in {
"server",
"Collector",
"EC2Reporter",
"TaskStatusReporter",
}:
return True
return None