From ae39af0ad86e40aca449b88f75eb64940fb3cb87 Mon Sep 17 00:00:00 2001 From: Jakub Stasiak Date: Tue, 10 Dec 2019 00:39:30 +0100 Subject: [PATCH] Simplify pytest configuration It seems to be doing fine on its own. As a bonus this restores running doctests from the injector source code which I broke when I made it a package (code in injector/__init__.py) instead of a simple module. *But* we need to start skipping running doctests for get_bindings on Python versions that don't support Annotated (or don't support it well enough). --- conftest.py | 7 ------- injector/__init__.py | 4 ++++ pytest.ini | 1 - setup.cfg | 3 --- 4 files changed, 4 insertions(+), 11 deletions(-) delete mode 100644 conftest.py diff --git a/conftest.py b/conftest.py deleted file mode 100644 index 0e35296..0000000 --- a/conftest.py +++ /dev/null @@ -1,7 +0,0 @@ -import os.path - -test_sources = ['injector', 'injector_test.py', 'README.md'] - - -def pytest_ignore_collect(path, config): - return not os.path.basename(str(path)) in test_sources diff --git a/injector/__init__.py b/injector/__init__.py index 189ac5d..c706552 100644 --- a/injector/__init__.py +++ b/injector/__init__.py @@ -1003,6 +1003,10 @@ def get_bindings(callable: Callable) -> Dict[str, type]: >>> get_bindings(function3) {'a': } + >>> import sys, pytest + >>> if sys.version_info < (3, 7, 0): + ... pytest.skip('Python 3.7.0 required for sufficient Annotated support') + >>> # The simple case of no @inject but injection requested with Inject[...] >>> def function4(a: Inject[int], b: str) -> None: ... pass diff --git a/pytest.ini b/pytest.ini index 61ea4bf..7c0b6fd 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,4 +1,3 @@ [pytest] -python_files = injector_test.py injector_test_py3.py addopts = -v --tb=native --doctest-glob=*.md --doctest-modules --cov-report term --cov-report html --cov-report xml --cov=injector --cov-branch norecursedirs = __pycache__ *venv* .git build diff --git a/setup.cfg b/setup.cfg index 549340e..e57d130 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,2 @@ -[pytest] -addopts = -rsxX -q --doctest-modules --doctest-glob=README.md injector injector_test.py README.md - [wheel] universal = True