From ab5af524a454585bc6ce02374964f198cbcf8670 Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Mon, 27 Aug 2018 15:34:56 +0200 Subject: [PATCH 1/6] Fix macOS specific code that uses capturemanager. https://github.com/pytest-dev/pytest/issues/3888#issuecomment-416206606 closes #3888 Co-authored-by: Bruno Oliveira --- changelog/3888.bugfix.rst | 1 + src/_pytest/doctest.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelog/3888.bugfix.rst diff --git a/changelog/3888.bugfix.rst b/changelog/3888.bugfix.rst new file mode 100644 index 000000000..17e00a828 --- /dev/null +++ b/changelog/3888.bugfix.rst @@ -0,0 +1 @@ +Fix macOS specific code using ``capturemanager`` plugin in doctests. diff --git a/src/_pytest/doctest.py b/src/_pytest/doctest.py index 57d3367e4..12b871f9f 100644 --- a/src/_pytest/doctest.py +++ b/src/_pytest/doctest.py @@ -203,7 +203,8 @@ class DoctestItem(pytest.Item): return capman = self.config.pluginmanager.getplugin("capturemanager") if capman: - out, err = capman.suspend_global_capture(in_=True) + capman.suspend_global_capture(in_=True) + out, err = capman.read_global_capture() sys.stdout.write(out) sys.stderr.write(err) From f786335dbbd54ddfad4595daa477124ceee9c82c Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Mon, 27 Aug 2018 16:13:43 +0200 Subject: [PATCH 2/6] travis: run tests on macOS closes #3892 --- .travis.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.travis.yml b/.travis.yml index 373b79289..98523ed8a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,6 +44,25 @@ jobs: python: '3.7' sudo: required dist: xenial + - &test-macos + language: generic + os: osx + osx_image: xcode9.4 + sudo: required + env: TOXENV=py27 + install: + - python -m pip install --upgrade --pre tox + - <<: *test-macos + env: TOXENV=py36 + install: + - python3 -m pip install --upgrade --pre tox + - <<: *test-macos + env: TOXENV=py37 + before_install: + - brew update + - brew upgrade python + - brew unlink python + - brew link python - stage: deploy python: '3.6' From 29e114b463946a2bc394c695be1b6885df8ed964 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 27 Aug 2018 19:27:51 -0300 Subject: [PATCH 3/6] Try to fix test in MacOS-X --- testing/python/fixture.py | 1 + 1 file changed, 1 insertion(+) diff --git a/testing/python/fixture.py b/testing/python/fixture.py index f8f5eb54e..fc3eee42b 100644 --- a/testing/python/fixture.py +++ b/testing/python/fixture.py @@ -1584,6 +1584,7 @@ class TestFixtureManagerParseFactories(object): values = [] """ ) + testdir.syspathinsert(testdir.tmpdir.dirname) package = testdir.mkdir("package") package.join("__init__.py").write("") package.join("conftest.py").write( From b2f7e02a02e60e8568440e080759436ef71e8ace Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 27 Aug 2018 19:30:55 -0300 Subject: [PATCH 4/6] Reorganize osx environments to avoid repetition as suggested in review --- .travis.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 98523ed8a..69544e608 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,13 +49,12 @@ jobs: os: osx osx_image: xcode9.4 sudo: required - env: TOXENV=py27 install: - - python -m pip install --upgrade --pre tox + - python -m pip install --pre tox + - <<: *test-macos + env: TOXENV=py27 - <<: *test-macos env: TOXENV=py36 - install: - - python3 -m pip install --upgrade --pre tox - <<: *test-macos env: TOXENV=py37 before_install: From a260e58020430a04ebdfbd1cafe7fcedcb23fc28 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 27 Aug 2018 20:03:12 -0300 Subject: [PATCH 5/6] Drop 3.6 from OS-X to reduce build time --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 69544e608..4937a180e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,8 +53,6 @@ jobs: - python -m pip install --pre tox - <<: *test-macos env: TOXENV=py27 - - <<: *test-macos - env: TOXENV=py36 - <<: *test-macos env: TOXENV=py37 before_install: From 32575f92c9b75b994876075b1a0902b8bebfaea3 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 27 Aug 2018 20:07:51 -0300 Subject: [PATCH 6/6] set TOXENV in test-macos template otherwise it will inherit "coveralls" --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4937a180e..832274b1d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,7 +51,6 @@ jobs: sudo: required install: - python -m pip install --pre tox - - <<: *test-macos env: TOXENV=py27 - <<: *test-macos env: TOXENV=py37