Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with timeout counting #180

Merged
merged 2 commits into from
Jan 1, 2025
Merged

Fix bug with timeout counting #180

merged 2 commits into from
Jan 1, 2025

Conversation

aklajnert
Copy link
Owner

No description provided.

@codecov-commenter
Copy link

codecov-commenter commented Jan 1, 2025

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
138 1 137 4
View the top 1 failed tests by shortest run time
tests/test_subprocess.py::::test_multiple_wait[True]
Stack Traces | 0.602s run time
fp = <pytest_subprocess.fake_process.FakeProcess object at 0x7f2129002f20>
fake = True

    @pytest.mark.flaky(reruns=2, condition=platform.python_implementation() == "PyPy")
    @pytest.mark.parametrize("fake", [False, True])
    def test_multiple_wait(fp, fake):
        """
        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.7,
            )
    
        process = subprocess.Popen(
            (PYTHON, "example_script.py", "wait"),
        )
        with pytest.raises(subprocess.TimeoutExpired):
            process.wait(timeout=0.2)
    
        with pytest.raises(subprocess.TimeoutExpired):
            process.wait(timeout=0.2)
    
        process.wait(0.6)
    
        assert process.returncode == 0
    
        # one more wait shall do no harm
>       process.wait(0.2)

.../pytest-subprocess/tests/test_subprocess.py:510: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pytest_subprocess.fake_popen.FakePopen object at 0x7f2129001f60>
timeout = 0.2

    def wait(self, timeout: Optional[float] = None) -> int:
        if timeout and self._wait_timeout and timeout < self._wait_timeout:
            self._wait_timeout -= timeout
>           raise subprocess.TimeoutExpired(self.args, timeout)
E           subprocess.TimeoutExpired: Command '('.../pytest-subprocess/pytest-subprocess/.nox.../tests-3-10/bin/python', 'example_script.py', 'wait')' timed out after 0.2 seconds

.../pytest-subprocess/pytest-subprocess/.nox.../tests-3-10/lib/python3.10.../site-packages/pytest_subprocess/fake_popen.py:146: TimeoutExpired

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

@aklajnert aklajnert force-pushed the fix_coverage branch 2 times, most recently from b430d5c to 1404bf4 Compare January 1, 2025 14:56
@aklajnert aklajnert changed the title Fix coverage action Fix bug with timeout counting Jan 1, 2025
@aklajnert aklajnert merged commit 2bc1692 into master Jan 1, 2025
22 checks passed
@aklajnert aklajnert deleted the fix_coverage branch January 1, 2025 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants