diff --git a/.travis.yml b/.travis.yml index 2f361aec006..d4240084470 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,7 @@ env: matrix: allow_failures: - python: '3.8-dev' - env: TOXENV=py38 + env: TOXENV=py38-xdist jobs: include: @@ -35,11 +35,11 @@ jobs: - env: TOXENV=pypy PYTEST_NO_COVERAGE=1 python: 'pypy-5.4' dist: trusty - - env: TOXENV=py34 + - env: TOXENV=py34-xdist python: '3.4' - - env: TOXENV=py35 + - env: TOXENV=py35-xdist python: '3.5' - - env: TOXENV=py36 + - env: TOXENV=py36-xdist python: '3.6' - env: TOXENV=py37 - &test-macos @@ -49,9 +49,9 @@ jobs: sudo: required install: - python -m pip install --pre tox - env: TOXENV=py27 + env: TOXENV=py27-xdist - <<: *test-macos - env: TOXENV=py37 + env: TOXENV=py37-xdist before_install: - brew update - brew upgrade python @@ -65,7 +65,7 @@ jobs: python: '3.7' - stage: cron_only - env: TOXENV=py38 + env: TOXENV=py38-xdist python: '3.8-dev' - stage: deploy diff --git a/appveyor.yml b/appveyor.yml index 2dea0180f26..773e16b1bc0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,12 +2,10 @@ environment: matrix: - TOXENV: "py37-xdist" - TOXENV: "py27-xdist" - - TOXENV: "py27" - - TOXENV: "py37" - TOXENV: "linting,docs,doctesting" - - TOXENV: "py36" - - TOXENV: "py35" - - TOXENV: "py34" + - TOXENV: "py34-xdist" + - TOXENV: "py35-xdist" + - TOXENV: "py36-xdist" - TOXENV: "pypy" PYTEST_NO_COVERAGE: "1" # Specialized factors for py27. diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index 33b76ec9caa..f0834d87033 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -280,7 +280,9 @@ def hasopt(self, char): def write_fspath_result(self, nodeid, res, **markup): fspath = self.config.rootdir.join(nodeid.split("::")[0]) - if fspath != self.currentfspath: + # NOTE: explicitly check for None to work around py bug, and for less + # overhead in general (https://github.com/pytest-dev/py/pull/207). + if self.currentfspath is None or fspath != self.currentfspath: if self.currentfspath is not None and self._show_progress_info: self._write_progress_information_filling_space() self.currentfspath = fspath diff --git a/testing/test_assertrewrite.py b/testing/test_assertrewrite.py index a852277cc2f..bfb6acfabf5 100644 --- a/testing/test_assertrewrite.py +++ b/testing/test_assertrewrite.py @@ -1308,10 +1308,17 @@ def test_simple_failure(): @pytest.mark.skipif( sys.platform.startswith("win32"), reason="cannot remove cwd on Windows" ) - def test_cwd_changed(self, testdir): + def test_cwd_changed(self, testdir, monkeypatch): + # Setup conditions for py's fspath trying to import pathlib on py34 + # always (previously triggered via xdist only). + # Ref: https://github.com/pytest-dev/py/pull/207 + monkeypatch.setattr(sys, "path", [""] + sys.path) + if "pathlib" in sys.modules: + del sys.modules["pathlib"] + testdir.makepyfile( **{ - "test_bar.py": """ + "test_setup_nonexisting_cwd.py": """ import os import shutil import tempfile @@ -1320,7 +1327,7 @@ def test_cwd_changed(self, testdir): os.chdir(d) shutil.rmtree(d) """, - "test_foo.py": """ + "test_test.py": """ def test(): pass """, diff --git a/tox.ini b/tox.ini index 8041abb0758..87d41989076 100644 --- a/tox.ini +++ b/tox.ini @@ -20,19 +20,22 @@ envlist = [testenv] commands = - {env:_PYTEST_TOX_COVERAGE_RUN:} pytest --lsof {posargs} + {env:_PYTEST_TOX_COVERAGE_RUN:} pytest {env:_PYTEST_TOX_ARGS:} {posargs} coverage: coverage combine coverage: coverage report passenv = USER USERNAME COVERAGE_* TRAVIS PYTEST_ADDOPTS setenv = + _PYTEST_TOX_ARGS=--lsof # Configuration to run with coverage similar to Travis/Appveyor, e.g. # "tox -e py37-coverage". coverage: _PYTEST_TOX_COVERAGE_RUN=coverage run -m coverage: _PYTEST_TOX_EXTRA_DEP=coverage-enable-subprocess coverage: COVERAGE_FILE={toxinidir}/.coverage coverage: COVERAGE_PROCESS_START={toxinidir}/.coveragerc + xdist: _PYTEST_TOX_ARGS={env:_PYTEST_TOX_ARGS:-n auto} extras = testing deps = + xdist: pytest-xdist>=1.13 {env:_PYTEST_TOX_EXTRA_DEP:} [testenv:py27-subprocess] @@ -50,22 +53,6 @@ basepython = python3 deps = pre-commit>=1.11.0 commands = pre-commit run --all-files --show-diff-on-failure -[testenv:py27-xdist] -extras = testing -deps = - {[testenv]deps} - pytest-xdist>=1.13 -commands = - {env:_PYTEST_TOX_COVERAGE_RUN:} pytest -n auto {posargs} - -[testenv:py37-xdist] -# NOTE: copied from above due to https://github.com/tox-dev/tox/issues/706. -extras = testing -deps = - {[testenv]deps} - pytest-xdist>=1.13 -commands = {[testenv:py27-xdist]commands} - [testenv:py27-pexpect] platform = linux|darwin deps =