diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0b26d2..d87afdf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,9 +33,11 @@ jobs: nox -s tests-${{ matrix.python-version }} env: PLATFORM: ${{ matrix.platform }} - - name: Update coverage - if: matrix.python-version != 'pypy3.8' - uses: codecov/codecov-action@v3 + - name: Upload test results to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} mypy: diff --git a/README.rst b/README.rst index 5e0925b..1dbc246 100644 --- a/README.rst +++ b/README.rst @@ -10,8 +10,8 @@ pytest-subprocess :target: https://pypi.org/project/pytest-subprocess :alt: Python versions -.. image:: https://codecov.io/gh/aklajnert/pytest-subprocess/branch/master/graph/badge.svg?token=JAU1cGoYL8 - :target: https://codecov.io/gh/aklajnert/pytest-subprocess +.. image:: https://codecov.io/github/aklajnert/pytest-subprocess/graph/badge.svg?token=JAU1cGoYL8 + :target: https://codecov.io/github/aklajnert/pytest-subprocess .. image:: https://readthedocs.org/projects/pytest-subprocess/badge/?version=latest :target: https://pytest-subprocess.readthedocs.io/en/latest/?badge=latest diff --git a/noxfile.py b/noxfile.py index fb77ddc..8268548 100644 --- a/noxfile.py +++ b/noxfile.py @@ -5,7 +5,12 @@ def tests(session): session.install(".[test]") session.run( - "coverage", "run", "-m", "pytest", "--timeout=300", "-v", *session.posargs + "pytest", + "--cov", + "--junitxml=junit.xml", + "-o", + "junit_family=legacy", + *session.posargs ) diff --git a/pytest_subprocess/fake_popen.py b/pytest_subprocess/fake_popen.py index e72a0c6..5188634 100644 --- a/pytest_subprocess/fake_popen.py +++ b/pytest_subprocess/fake_popen.py @@ -141,9 +141,10 @@ def poll(self) -> Optional[int]: return self.returncode def wait(self, timeout: Optional[float] = None) -> int: - if timeout and self._wait_timeout and timeout < self._wait_timeout: + if timeout and self._wait_timeout: self._wait_timeout -= timeout - raise subprocess.TimeoutExpired(self.args, timeout) + if timeout < self._wait_timeout: + raise subprocess.TimeoutExpired(self.args, timeout) self._finalize_thread(timeout) if self.returncode is None: raise exceptions.PluginInternalError diff --git a/setup.py b/setup.py index 23022ca..48cfca1 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,7 @@ def read(fname): extras_require={ "test": [ "pytest>=4.0", - "coverage", + "pytest-cov", "docutils>=0.12", "Pygments>=2.0", "pytest-rerunfailures", diff --git a/tests/test_subprocess.py b/tests/test_subprocess.py index 67c703e..9081537 100644 --- a/tests/test_subprocess.py +++ b/tests/test_subprocess.py @@ -482,15 +482,15 @@ def test_ambiguous_input(fp, fake): @pytest.mark.parametrize("fake", [False, True]) def test_multiple_wait(fp, fake): """ - Wait multiple times for 0.2 seconds with process lasting for 0.5. - Third wait shall is a bit longer and will not raise an exception, + Wait multiple times for 0.2 seconds with process lasting for 0.7. + Third wait shall be a bit longer and will not raise an exception, due to exceeding the subprocess runtime. """ fp.allow_unregistered(not fake) if fake: fp.register( [PYTHON, "example_script.py", "wait"], - wait=0.5, + wait=0.7, ) process = subprocess.Popen( @@ -500,9 +500,9 @@ def test_multiple_wait(fp, fake): process.wait(timeout=0.2) with pytest.raises(subprocess.TimeoutExpired): - process.wait(timeout=0.1) + process.wait(timeout=0.2) - process.wait(0.4) + process.wait(0.6) assert process.returncode == 0