Skip to content

Commit

Permalink
add upstream test target with contrib allowed to fail
Browse files Browse the repository at this point in the history
  • Loading branch information
tfranzel committed Jun 21, 2020
1 parent 5e09382 commit bfe7afc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,21 @@ jobs:
env: TOXENV=py38-django3.0-drf3.10
- python: 3.8
env: TOXENV=py38-django3.0-drf3.11

- python: 3.8
env: TOXENV=py38-django3.0-drfmaster
- python: 3.8
env: TOXENV=py38-djangomaster-drf3.11
- python: 3.8
env: TOXENV=py38-drfmaster-djangomaster
- python: 3.8
env: TOXENV=py38-drfmaster-djangomaster-allowcontribfail

allow_failures:
- env: TOXENV=py38-django3.0-drfmaster
- env: TOXENV=py38-djangomaster-drf3.11
- env: TOXENV=py38-drfmaster-djangomaster
- env: TOXENV=py38-drfmaster-djangomaster-allowcontribfail

install:
- pip install -U pip
Expand Down
17 changes: 13 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ def pytest_configure(config):
contrib_apps = [
'rest_framework_jwt',
'oauth2_provider',
'polymorphic',
# this is not strictly required and when added django-polymorphic
# currently breaks the whole Django/DRF upstream testing.
# 'polymorphic',
]

settings.configure(
Expand Down Expand Up @@ -89,17 +91,24 @@ def pytest_addoption(parser):
default=False,
help="skip tests depending on missing contrib packages"
)
parser.addoption(
"--allow-contrib-fail",
action="store_true",
default=False,
help="run contrib tests but allow them to fail"
)


def pytest_collection_modifyitems(config, items):
if not config.getoption("--skip-missing-contrib"):
return
skip_missing_contrib = pytest.mark.skip(reason="skip tests for missing contrib package")
allow_contrib_fail = pytest.mark.xfail(reason="contrib test were allowed to fail")
for item in items:
for marker in item.own_markers:
if marker.name == 'contrib':
if marker.name == 'contrib' and config.getoption("--skip-missing-contrib"):
if not all([module_available(module_str) for module_str in marker.args]):
item.add_marker(skip_missing_contrib)
if marker.name == 'contrib' and config.getoption("--allow-contrib-fail"):
item.add_marker(allow_contrib_fail)


@pytest.fixture()
Expand Down
6 changes: 5 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ envlist =
py38-django3.0-drfmaster
py38-djangomaster-drf3.11
py38-drfmaster-djangomaster
py38-drfmaster-djangomaster-allowcontribfail
skip_missing_interpreters = true

[testenv]
Expand All @@ -26,6 +27,9 @@ deps =
-r requirements/testing.txt
-r requirements/optionals.txt

[testenv:py38-drfmaster-djangomaster-allowcontribfail]
commands = ./runtests.py {posargs:--fast --cov=drf_spectacular --cov=tests --allow-contrib-fail}

[testenv:lint]
commands = ./runtests.py --lintonly
deps =
Expand Down Expand Up @@ -95,4 +99,4 @@ ignore_missing_imports = True
ignore_missing_imports = True

[mypy-djangorestframework_camel_case.util.*]
ignore_missing_imports = True
ignore_missing_imports = True

0 comments on commit bfe7afc

Please sign in to comment.