Skip to content

Commit

Permalink
invoke pytest directly instead of through the setup.py file (#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
dirk-thomas authored Jan 30, 2020
1 parent d4c0d27 commit 01d3eb0
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ env:
install:
- pip install -U setuptools
# install_requires
- pip install -U distlib EmPy pytest-rerunfailures pytest pytest-cov pytest-repeat pytest-runner
- pip install -U distlib EmPy pytest-rerunfailures pytest pytest-cov pytest-repeat
# additional tests_require
- pip install -U flake8-blind-except flake8-builtins flake8-class-newline flake8-comprehensions flake8-deprecated flake8-docstrings flake8-quotes pep8-naming pylint scspell3k
# for uploading the coverage information to codecov
Expand Down
14 changes: 5 additions & 9 deletions colcon_core/task/python/test/pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from colcon_core.task.python.test import has_test_dependency
from colcon_core.task.python.test import PythonTestingStepExtensionPoint
from colcon_core.verb.test import logger
from pkg_resources import iter_entry_points
from pkg_resources import parse_version


Expand All @@ -29,9 +28,10 @@ def __init__(self): # noqa: D107
satisfies_version(
PythonTestingStepExtensionPoint.EXTENSION_POINT_VERSION, '^1.0')

entry_points = iter_entry_points('distutils.commands', name='pytest')
if not list(entry_points):
raise SkipExtensionException("'pytest-runner' not found")
try:
import pytest # noqa: F401
except ImportError:
raise SkipExtensionException("'pytest' not found")

def add_arguments(self, *, parser): # noqa: D102
parser.add_argument(
Expand All @@ -49,11 +49,7 @@ def match(self, context, env, setup_py_data): # noqa: D102
return has_test_dependency(setup_py_data, 'pytest')

async def step(self, context, env, setup_py_data): # noqa: D102
cmd = [
sys.executable,
'setup.py', 'pytest',
'egg_info', '--egg-base', context.args.build_base,
]
cmd = [sys.executable, '-m', 'pytest']
junit_xml_path = Path(
context.args.test_result_base
if context.args.test_result_base
Expand Down
2 changes: 1 addition & 1 deletion debian/patches/setup.cfg.patch
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ Author: Dirk Thomas <[email protected]>
+ # would result in a runtime error by pkg_resources
+ # pytest-repeat
+ # pytest-rerunfailures
pytest-runner
setuptools>=30.3.0
packages = find:
tests_require =
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ install_requires =
pytest-cov
pytest-repeat
pytest-rerunfailures
pytest-runner
setuptools>=30.3.0
packages = find:
tests_require =
Expand Down
2 changes: 1 addition & 1 deletion stdeb.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[colcon-core]
No-Python2:
Depends3: python3-distlib, python3-empy, python3-pytest, python3-pytest-cov, python3-pytest-runner, python3-setuptools
Depends3: python3-distlib, python3-empy, python3-pytest, python3-pytest-cov, python3-setuptools
Suite: xenial bionic focal stretch buster
X-Python3-Version: >= 3.5

0 comments on commit 01d3eb0

Please sign in to comment.