Hello community, here is the log from the commit of package python-pytest-timeout for openSUSE:Factory checked in at 2020-11-09 13:56:22 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-pytest-timeout (Old) and /work/SRC/openSUSE:Factory/.python-pytest-timeout.new.11331 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pytest-timeout" Mon Nov 9 13:56:22 2020 rev:10 rq:846349 version:1.4.2 Changes: -------- --- /work/SRC/openSUSE:Factory/python-pytest-timeout/python-pytest-timeout.changes 2020-06-30 21:54:40.050425099 +0200 +++ /work/SRC/openSUSE:Factory/.python-pytest-timeout.new.11331/python-pytest-timeout.changes 2020-11-09 13:56:49.088041741 +0100 @@ -1,0 +2,6 @@ +Thu Nov 5 14:37:31 UTC 2020 - Marketa Machova <mmach...@suse.com> + +- Update to 1.4.2 + * Fix is_debugging function + +------------------------------------------------------------------- Old: ---- pytest-timeout-1.4.1.tar.gz New: ---- pytest-timeout-1.4.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-pytest-timeout.spec ++++++ --- /var/tmp/diff_new_pack.XFiPxo/_old 2020-11-09 13:56:50.336039019 +0100 +++ /var/tmp/diff_new_pack.XFiPxo/_new 2020-11-09 13:56:50.336039019 +0100 @@ -18,7 +18,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-pytest-timeout -Version: 1.4.1 +Version: 1.4.2 Release: 0 Summary: Pytest plugin to abort hanging tests License: MIT ++++++ pytest-timeout-1.4.1.tar.gz -> pytest-timeout-1.4.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-timeout-1.4.1/PKG-INFO new/pytest-timeout-1.4.2/PKG-INFO --- old/pytest-timeout-1.4.1/PKG-INFO 2020-06-15 21:23:07.425450000 +0200 +++ new/pytest-timeout-1.4.2/PKG-INFO 2020-07-15 21:25:23.076116000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: pytest-timeout -Version: 1.4.1 +Version: 1.4.2 Summary: py.test plugin to abort hanging tests Home-page: http://github.com/pytest-dev/pytest-timeout/ Author: Floris Bruynooghe @@ -209,6 +209,13 @@ Changelog ========= + 1.4.2 + ----- + + - Fix compatibility when run with pytest pre-releases, thanks + Bruno Oliveira, + - Fix detection of third-party debuggers, thanks Bruno Oliveira. + 1.4.1 ----- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-timeout-1.4.1/README.rst new/pytest-timeout-1.4.2/README.rst --- old/pytest-timeout-1.4.1/README.rst 2020-06-15 21:03:43.000000000 +0200 +++ new/pytest-timeout-1.4.2/README.rst 2020-07-15 21:24:43.000000000 +0200 @@ -201,6 +201,13 @@ Changelog ========= +1.4.2 +----- + +- Fix compatibility when run with pytest pre-releases, thanks + Bruno Oliveira, +- Fix detection of third-party debuggers, thanks Bruno Oliveira. + 1.4.1 ----- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-timeout-1.4.1/pytest_timeout.egg-info/PKG-INFO new/pytest-timeout-1.4.2/pytest_timeout.egg-info/PKG-INFO --- old/pytest-timeout-1.4.1/pytest_timeout.egg-info/PKG-INFO 2020-06-15 21:23:07.000000000 +0200 +++ new/pytest-timeout-1.4.2/pytest_timeout.egg-info/PKG-INFO 2020-07-15 21:25:23.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: pytest-timeout -Version: 1.4.1 +Version: 1.4.2 Summary: py.test plugin to abort hanging tests Home-page: http://github.com/pytest-dev/pytest-timeout/ Author: Floris Bruynooghe @@ -209,6 +209,13 @@ Changelog ========= + 1.4.2 + ----- + + - Fix compatibility when run with pytest pre-releases, thanks + Bruno Oliveira, + - Fix detection of third-party debuggers, thanks Bruno Oliveira. + 1.4.1 ----- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-timeout-1.4.1/pytest_timeout.py new/pytest-timeout-1.4.2/pytest_timeout.py --- old/pytest-timeout-1.4.1/pytest_timeout.py 2020-06-15 21:19:03.000000000 +0200 +++ new/pytest-timeout-1.4.2/pytest_timeout.py 2020-07-15 21:20:47.000000000 +0200 @@ -13,7 +13,7 @@ import threading import traceback from collections import namedtuple -from distutils.version import StrictVersion +from distutils.version import LooseVersion import py import pytest @@ -156,7 +156,7 @@ SUPPRESS_TIMEOUT = True -def is_debugging(): +def is_debugging(trace_func=None): """Detect if a debugging session is in progress. This looks at both pytest's builtin pdb support as well as @@ -168,14 +168,19 @@ 1. Examines the trace function to see if the module it originates from is in KNOWN_DEBUGGING_MODULES. 2. Check is SUPPRESS_TIMEOUT is set to True. + + :param trace_func: the current trace function, if not given will use + sys.gettrace(). Used to unit-test this function. """ global SUPPRESS_TIMEOUT, KNOWN_DEBUGGING_MODULES if SUPPRESS_TIMEOUT: return True - trace_func = sys.gettrace() + if trace_func is None: + trace_func = sys.gettrace() if trace_func and inspect.getmodule(trace_func): + parts = inspect.getmodule(trace_func).__name__.split(".") for name in KNOWN_DEBUGGING_MODULES: - if name in inspect.getmodule(trace_func): + if name in parts: return True return False @@ -381,8 +386,8 @@ try: capman = item.config.pluginmanager.getplugin("capturemanager") if capman: - pytest_version = StrictVersion(pytest.__version__) - if pytest_version >= StrictVersion("3.7.3"): + pytest_version = LooseVersion(pytest.__version__) + if pytest_version >= LooseVersion("3.7.3"): capman.suspend_global_capture(item) stdout, stderr = capman.read_global_capture() else: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-timeout-1.4.1/setup.py new/pytest-timeout-1.4.2/setup.py --- old/pytest-timeout-1.4.1/setup.py 2020-06-15 21:22:37.000000000 +0200 +++ new/pytest-timeout-1.4.2/setup.py 2020-07-15 21:24:51.000000000 +0200 @@ -11,7 +11,7 @@ name="pytest-timeout", description="py.test plugin to abort hanging tests", long_description=long_description, - version="1.4.1", + version="1.4.2", author="Floris Bruynooghe", author_email="f...@devork.be", url="http://github.com/pytest-dev/pytest-timeout/", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-timeout-1.4.1/test_pytest_timeout.py new/pytest-timeout-1.4.2/test_pytest_timeout.py --- old/pytest-timeout-1.4.1/test_pytest_timeout.py 2020-06-15 21:19:02.000000000 +0200 +++ new/pytest-timeout-1.4.2/test_pytest_timeout.py 2020-07-15 21:20:47.000000000 +0200 @@ -31,9 +31,9 @@ def test_x(): pass """ ) - result = testdir.runpytest("--timeout=1") + result = testdir.runpytest("--timeout=0.01") result.stdout.fnmatch_lines( - ["timeout: 1.0s", "timeout method:*", "timeout func_only:*"] + ["timeout: 0.01s", "timeout method:*", "timeout func_only:*"] ) @@ -47,8 +47,8 @@ time.sleep(2) """ ) - result = testdir.runpytest("--timeout=1.5") - result.stdout.fnmatch_lines(["*Failed: Timeout >1.5s*"]) + result = testdir.runpytest("--timeout=0.01") + result.stdout.fnmatch_lines(["*Failed: Timeout >0.01s*"]) def test_thread(testdir): @@ -60,7 +60,7 @@ time.sleep(2) """ ) - result = testdir.runpytest("--timeout=1", "--timeout-method=thread") + result = testdir.runpytest("--timeout=0.01", "--timeout-method=thread") result.stderr.fnmatch_lines( [ "*++ Timeout ++*", @@ -86,7 +86,7 @@ """ ) result = testdir.runpytest( - "--timeout=1", "--cov=test_cov.py", "--timeout-method=thread" + "--timeout=0.01", "--cov=test_cov.py", "--timeout-method=thread" ) result.stderr.fnmatch_lines( [ @@ -108,7 +108,7 @@ time.sleep(2) """ ) - monkeypatch.setitem(os.environ, "PYTEST_TIMEOUT", "1") + monkeypatch.setitem(os.environ, "PYTEST_TIMEOUT", "0.01") result = testdir.runpytest() assert result.ret > 0 @@ -150,7 +150,7 @@ scope=scope ) ) - result = testdir.runpytest("--timeout=1", "--timeout-method={}".format(meth)) + result = testdir.runpytest("--timeout=0.01", "--timeout-method={}".format(meth)) assert result.ret > 0 assert "Timeout" in result.stdout.str() + result.stderr.str() @@ -164,14 +164,14 @@ @pytest.fixture def fix(self): - time.sleep(2) + time.sleep(0.1) @pytest.mark.timeout(func_only=True) def test_foo(self, fix): pass """ ) - result = testdir.runpytest("--timeout=1") + result = testdir.runpytest("--timeout=0.01") assert result.ret == 0 assert "Timeout" not in result.stdout.str() + result.stderr.str() @@ -197,7 +197,9 @@ pass """ ) - result = testdir.runpytest("--timeout=1", "-s", "--timeout-method={}".format(meth)) + result = testdir.runpytest( + "--timeout=0.01", "-s", "--timeout-method={}".format(meth) + ) assert result.ret > 0 assert "Timeout" in result.stdout.str() + result.stderr.str() @@ -214,7 +216,7 @@ print('fix setup') def fin(): print('fix finaliser') - time.sleep(2) + time.sleep(0.1) request.addfinalizer(fin) @pytest.mark.timeout(func_only=True) @@ -222,7 +224,7 @@ pass """ ) - result = testdir.runpytest("--timeout=1", "-s") + result = testdir.runpytest("--timeout=0.01", "-s") assert result.ret == 0 assert "Timeout" not in result.stdout.str() + result.stderr.str() @@ -233,14 +235,14 @@ """ import time, pytest - @pytest.mark.timeout(1) + @pytest.mark.timeout(0.01) def test_foo(): time.sleep(2) assert False """ ) result = testdir.runpytest() - result.stdout.fnmatch_lines(["*Failed: Timeout >1.0s*"]) + result.stdout.fnmatch_lines(["*Failed: Timeout >0.01s*"]) def test_timeout_mark_timer(testdir): @@ -248,7 +250,7 @@ """ import time, pytest - @pytest.mark.timeout(1) + @pytest.mark.timeout(0.01) def test_foo(): time.sleep(2) """ @@ -262,7 +264,7 @@ """ import time, pytest - @pytest.mark.timeout(0.5) + @pytest.mark.timeout(0.01) def test_foo(): time.sleep(1) """ @@ -304,7 +306,7 @@ """ import time, pytest - @pytest.mark.timeout(1, 'thread') + @pytest.mark.timeout(0.01, 'thread') def test_foo(): time.sleep(2) """ @@ -339,7 +341,7 @@ testdir.makeini( """ [pytest] - timeout = 1.5 + timeout = 0.01 """ ) result = testdir.runpytest() @@ -353,7 +355,7 @@ @pytest.fixture def slow(): - time.sleep(2) + time.sleep(0.1) def test_foo(slow): pass @@ -362,7 +364,7 @@ testdir.makeini( """ [pytest] - timeout = 1.5 + timeout = 0.01 timeout_func_only = true """ ) @@ -382,7 +384,7 @@ testdir.makeini( """ [pytest] - timeout = 1 + timeout = 0.01 timeout_method = thread """ ) @@ -395,19 +397,18 @@ """ import time, pytest - @pytest.mark.timeout(timeout=2) + @pytest.mark.timeout(timeout=0.05) class TestFoo: - @pytest.mark.timeout(timeout=3) + @pytest.mark.timeout(timeout=0.5) def test_foo_2(self): - time.sleep(2) + time.sleep(0.1) - @pytest.mark.timeout(timeout=3) def test_foo_1(self): - time.sleep(1) + time.sleep(0.01) """ ) - result = testdir.runpytest("--timeout=1", "-s") + result = testdir.runpytest("--timeout=0.01", "-s") assert result.ret == 0 assert "Timeout" not in result.stdout.str() + result.stderr.str() @@ -444,7 +445,7 @@ """ import pytest, {debugging_module} - @pytest.mark.timeout(1) + @pytest.mark.timeout(0.1) def test_foo(): {debugging_module}.{debugging_set_trace} """.format( @@ -453,11 +454,32 @@ ) child = testdir.spawn_pytest(str(p1)) child.expect("test_foo") - time.sleep(2) + time.sleep(0.2) child.send("c\n") child.sendeof() result = child.read().decode().lower() if child.isalive(): child.terminate(force=True) - assert "timeout >1.0s" not in result + assert "timeout >0.01s" not in result assert "fail" not in result + + +def test_is_debugging(monkeypatch): + import pytest_timeout + + assert not pytest_timeout.is_debugging() + + # create a fake module named "custom.pydevd" with a trace function on it + from types import ModuleType + + module_name = "custom.pydevd" + module = ModuleType(module_name) + monkeypatch.setitem(sys.modules, module_name, module) + + def custom_trace(*args): + pass + + custom_trace.__module__ = module_name + module.custom_trace = custom_trace + + assert pytest_timeout.is_debugging(custom_trace)