Skip to content

Commit

Permalink
TST: Use pytest-xdist
Browse files Browse the repository at this point in the history
hypothesis tests become flaky with pytest-xdist due to timing issues
when initializing values to draw from. This change removes the separate
hypothesis profiles for ci and disables hypothesis deadlines by default.

The ci/ci-fast profiles are removed because the timing difference between
them are barely different when the tests are parallelized.
  • Loading branch information
mferrera committed Oct 25, 2023
1 parent abe3648 commit f382764
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [main]

jobs:
fast:
test:
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
Expand Down Expand Up @@ -35,8 +35,8 @@ jobs:
- name: Setup testdata
uses: "./.github/actions/setup_testdata"

- name: Run fast tests
run: pytest --disable-warnings -x --hypothesis-profile ci-fast
- name: Run tests
run: pytest -n 4 tests --disable-warnings

hypothesis:
runs-on: ubuntu-latest
Expand All @@ -54,7 +54,7 @@ jobs:
uses: "./.github/actions/setup_testdata"

- name: Run just hypothesis tests with more examples
run: python -m pytest --disable-warnings -x -m hypothesis --hypothesis-profile ci --generate-plots
run: pytest -n 4 tests --disable-warnings -m hypothesis --generate-plots

big:
runs-on: ubuntu-latest
Expand All @@ -72,7 +72,7 @@ jobs:
uses: "./.github/actions/setup_testdata"

- name: Run just tests marked big
run: XTG_BIGTEST=1 python -m pytest --disable-warnings -x -m bigtest --hypothesis-profile ci --generate-plots
run: XTG_BIGTEST=1 pytest -n 4 tests --disable-warnings -m bigtest --generate-plots

codecov:
runs-on: ubuntu-latest
Expand All @@ -89,9 +89,8 @@ jobs:
- name: Setup testdata
uses: "./.github/actions/setup_testdata"


- name: Generate coverage report
run: pytest tests --doctest-modules --generate-plots --disable-warnings --cov=xtgeo --hypothesis-profile ci-fast --cov-report=xml:xtgeocoverage.xml;
run: pytest -n 4 tests --doctest-modules --generate-plots --disable-warnings --cov=xtgeo --cov-report=xml:xtgeocoverage.xml;

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
Expand Down
7 changes: 2 additions & 5 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@
from hypothesis import HealthCheck, settings

settings.register_profile(
"ci", max_examples=250, deadline=None, suppress_health_check=[HealthCheck.too_slow]
)
settings.register_profile(
"ci-fast",
max_examples=10,
"no_timeouts",
deadline=None,
suppress_health_check=[HealthCheck.too_slow],
)
settings.load_profile("no_timeouts")


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ before-test = [
test-command = [
"pushd {package}",
# Ignore forking tests as they do not work well with CIBW
'pytest --disable-warnings -x -m "not hypothesis" --ignore tests/test_well --ignore-glob="*forks.py"',
'pytest -n 4 tests --disable-warnings -m "not hypothesis" --ignore tests/test_well --ignore-glob="*forks.py"',
]

[tool.isort]
Expand Down

0 comments on commit f382764

Please sign in to comment.