| 1 | #!/bin/bash |
| 2 | set -e -o xtrace |
| 3 | |
| 4 | HERE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 5 | cd "$HERE/.." |
| 6 | |
| 7 | pip install . |
| 8 | |
| 9 | |
| 10 | PYTEST="python -bb -X dev -m pytest -nauto --durations-min=1.0" |
| 11 | |
| 12 | # Run some tests without docstrings or assertions, to catch bugs |
| 13 | # like issue #822 in one of the test decorators. See also #1541. |
| 14 | PYTHONOPTIMIZE=2 $PYTEST \ |
| 15 | -W'ignore:assertions not in test modules or plugins will be ignored because assert statements are not executed by the underlying Python interpreter:pytest.PytestConfigWarning' \ |
| 16 | -W'ignore:Module already imported so cannot be rewritten:pytest.PytestAssertRewriteWarning' \ |
| 17 | tests/cover/test_testdecorators.py |
| 18 | |
| 19 | # Run tests for each extra module while the requirements are installed |
| 20 | pip install ".[pytz, dateutil, zoneinfo]" |
| 21 | $PYTEST tests/datetime/ |
| 22 | pip uninstall -y pytz python-dateutil |
| 23 | |
| 24 | pip install ".[dpcontracts]" |
| 25 | $PYTEST tests/dpcontracts/ |
| 26 | pip uninstall -y dpcontracts |
| 27 | |
| 28 | pip install attrs |
| 29 | $PYTEST tests/attrs/ |
| 30 | pip uninstall -y attrs |
| 31 | |
| 32 | # use pinned redis version instead of inheriting from fakeredis |
| 33 | pip install "$(grep '^redis==' ../requirements/coverage.txt)" |
| 34 | pip install "$(grep 'fakeredis==' ../requirements/coverage.txt)" |
| 35 | pip install "$(grep 'typing-extensions==' ../requirements/coverage.txt)" |
| 36 | $PYTEST tests/redis/ |
| 37 | pip uninstall -y redis fakeredis |
| 38 | |
| 39 | $PYTEST tests/typing_extensions/ |
| 40 | if [ "$HYPOTHESIS_PROFILE" != "crosshair" ] && [ "$(python -c 'import sys; print(sys.version_info[:2] > (3, 10))')" = "True" ]; then |
| 41 | pip uninstall -y typing-extensions |
| 42 | fi |
| 43 | |
| 44 | pip install "$(grep 'annotated-types==' ../requirements/coverage.txt)" |
| 45 | $PYTEST tests/test_annotated_types.py |
| 46 | pip uninstall -y annotated-types |
| 47 | |
| 48 | pip install ".[lark]" |
| 49 | pip install "$(grep -m 1 -oE 'lark>=([0-9.]+)' ../hypothesis-python/pyproject.toml | tr '>' =)" |
| 50 | $PYTEST -Wignore tests/lark/ |
| 51 | pip install "$(grep 'lark==' ../requirements/coverage.txt)" |
| 52 | $PYTEST tests/lark/ |
| 53 | pip uninstall -y lark |
| 54 | |
| 55 | if [ "$(python -c $'import platform, sys; print(sys.version_info.releaselevel == \'final\' and platform.python_implementation() not in ("PyPy", "GraalVM"))')" = "True" ] ; then |
| 56 | pip install ".[codemods,cli]" |
| 57 | $PYTEST tests/codemods/ |
| 58 | |
| 59 | if [ "$(python -c 'import sys; print(sys.version_info[:2] == (3, 10))')" = "True" ] ; then |
| 60 | # Per NEP-29, this is the last version to support Python 3.10 |
| 61 | pip install numpy==2.2.6 |
| 62 | else |
| 63 | pip install "$(grep 'numpy==' ../requirements/coverage.txt)" |
| 64 | fi |
| 65 | |
| 66 | pip install "$(grep -E 'black(==| @)' ../requirements/coverage.txt)" |
| 67 | $PYTEST tests/patching/ |
| 68 | pip uninstall -y libcst |
| 69 | |
| 70 | # One of the ghostwriter tests uses attrs (though hypothesis[ghostwriter] does not require attrs). |
| 71 | pip install attrs |
| 72 | $PYTEST tests/ghostwriter/ |
| 73 | pip uninstall -y attrs |
| 74 | pip uninstall -y black |
| 75 | |
| 76 | if [ "$HYPOTHESIS_PROFILE" != "crosshair" ] ; then |
| 77 | # Crosshair tracer is not compatible with no-gil |
| 78 | if [ "$(python -c "import sys; print('free-threading' in sys.version)")" != "True" ] ; then |
| 79 | # Run twice, interleaved by other tests, to make it more probable to tickle any problems |
| 80 | # from accidentally caching/retaining crosshair proxy objects |
| 81 | pip install pytest-repeat |
| 82 | pip install -r ../requirements/crosshair.txt |
| 83 | # requirements/crosshair.txt pins hypothesis. Re-override it with our local changes |
| 84 | pip install . |
| 85 | $PYTEST --count=2 --repeat-scope=session tests/numpy tests/crosshair |
| 86 | # ...but running twice takes time, don't overdo it |
| 87 | $PYTEST tests/array_api |
| 88 | else |
| 89 | $PYTEST tests/array_api tests/numpy |
| 90 | fi |
| 91 | fi |
| 92 | fi |