forked from astropy/astropy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
72 lines (59 loc) · 2.52 KB
/
Copy pathconftest.py
File metadata and controls
72 lines (59 loc) · 2.52 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Licensed under a 3-clause BSD style license - see LICENSE.rst
# This file is the main file used when running tests with pytest directly,
# in particular if running e.g. ``pytest docs/``.
import os
import hypothesis
from astropy import __version__
try:
from pytest_astropy_header.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS
except ImportError:
PYTEST_HEADER_MODULES = {}
TESTED_VERSIONS = {}
# This has to be in the root dir or it will not display in CI.
def pytest_configure(config):
# Strip COLUMNS/LINES so shutil.get_terminal_size() falls back to (80, 24)
# in the test session. Interactive shells (bash, zsh) export these on
# window resize, and pytest inherits them, so otherwise tests and doctests
# that read the terminal size are non-deterministic across environments.
os.environ.pop("COLUMNS", None)
os.environ.pop("LINES", None)
PYTEST_HEADER_MODULES["PyERFA"] = "erfa"
PYTEST_HEADER_MODULES["Cython"] = "cython"
PYTEST_HEADER_MODULES["Scikit-image"] = "skimage"
PYTEST_HEADER_MODULES["pyarrow"] = "pyarrow"
PYTEST_HEADER_MODULES["asdf-astropy"] = "asdf_astropy"
TESTED_VERSIONS["Astropy"] = __version__
# This has to be in the root dir or it will not display in CI.
def pytest_report_header(config):
# This gets added after the pytest-astropy-header output.
return (
f"CI: {os.environ.get('CI', 'undefined')}\n"
f"ARCH_ON_CI: {os.environ.get('ARCH_ON_CI', 'undefined')}\n"
f"IS_CRON: {os.environ.get('IS_CRON', 'undefined')}\n"
)
# Tell Hypothesis that we might be running slow tests, to print the seed blob
# so we can easily reproduce failures from CI, and derive a fuzzing profile
# to try many more inputs when we detect a scheduled build or when specifically
# requested using the HYPOTHESIS_PROFILE=fuzz environment variable or
# `pytest --hypothesis-profile=fuzz ...` argument.
hypothesis.settings.register_profile(
"ci",
deadline=None,
print_blob=True,
derandomize=True,
# disabling HealthCheck.differing_executors to allow double test
# see https://github.com/astropy/astropy/issues/17299
suppress_health_check=[hypothesis.HealthCheck.differing_executors],
)
hypothesis.settings.register_profile(
"fuzzing", deadline=None, print_blob=True, max_examples=1000
)
default = (
"fuzzing"
if (
os.environ.get("IS_CRON") == "true"
and os.environ.get("ARCH_ON_CI") not in ("aarch64", "ppc64le")
)
else "ci"
)
hypothesis.settings.load_profile(os.environ.get("HYPOTHESIS_PROFILE", default))