Skip to content

Commit

Permalink
remove marker support, update description
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Peters authored and flub committed Feb 3, 2023
1 parent 198b792 commit 6c3a5b4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 58 deletions.
18 changes: 4 additions & 14 deletions pytest_timeout.py
Expand Up @@ -42,7 +42,7 @@
""".strip()
DISABLE_DEBUGGER_DETECTION_DESC = """
When specified, disables debugger detection. breakpoint(), pdb.set_trace(), etc.
will be interrupted.
will be interrupted by the timeout.
""".strip()

# bdb covers pdb, ipdb, and possibly others
Expand Down Expand Up @@ -364,16 +364,14 @@ def _parse_marker(marker):
"""
if not marker.args and not marker.kwargs:
raise TypeError("Timeout marker must have at least one argument")
timeout = method = func_only = disable_debugger_detection = NOTSET = object()
timeout = method = func_only = NOTSET = object()
for kw, val in marker.kwargs.items():
if kw == "timeout":
timeout = val
elif kw == "method":
method = val
elif kw == "func_only":
func_only = val
elif kw == "disable_debugger_detection":
disable_debugger_detection = val
else:
raise TypeError("Invalid keyword argument for timeout marker: %s" % kw)
if len(marker.args) >= 1 and timeout is not NOTSET:
Expand All @@ -384,23 +382,15 @@ def _parse_marker(marker):
raise TypeError("Multiple values for method argument of timeout marker")
elif len(marker.args) >= 2:
method = marker.args[1]
if len(marker.args) >= 3 and disable_debugger_detection is not NOTSET:
raise TypeError(
"Multiple values for disable_debugger_detection argument of timeout marker"
)
elif len(marker.args) >= 3:
disable_debugger_detection = marker.args[2]
if len(marker.args) > 3:
if len(marker.args) > 2:
raise TypeError("Too many arguments for timeout marker")
if timeout is NOTSET:
timeout = None
if method is NOTSET:
method = None
if func_only is NOTSET:
func_only = None
if disable_debugger_detection is NOTSET:
disable_debugger_detection = None
return Settings(timeout, method, func_only, disable_debugger_detection)
return Settings(timeout, method, func_only, None)


def _validate_timeout(timeout, where):
Expand Down
44 changes: 0 additions & 44 deletions test_pytest_timeout.py
Expand Up @@ -530,50 +530,6 @@ def test_foo():
assert "fail" in result


@pytest.mark.parametrize(
["debugging_module", "debugging_set_trace"],
[
("pdb", "set_trace()"),
pytest.param(
"ipdb",
"set_trace()",
marks=pytest.mark.xfail(
reason="waiting on https://github.com/pytest-dev/pytest/pull/7207"
" to allow proper testing"
),
),
pytest.param(
"pydevd",
"settrace(port=4678)",
marks=pytest.mark.xfail(reason="in need of way to setup pydevd server"),
),
],
)
@have_spawn
def test_disable_debugger_detection_marker(
testdir, debugging_module, debugging_set_trace
):
p1 = testdir.makepyfile(
"""
import pytest, {debugging_module}
@pytest.mark.timeout(1, disable_debugger_detection=True)
def test_foo():
{debugging_module}.{debugging_set_trace}
""".format(
debugging_module=debugging_module, debugging_set_trace=debugging_set_trace
)
)
child = testdir.spawn_pytest(str(p1))
child.expect("test_foo")
time.sleep(1.2)
result = child.read().decode().lower()
if child.isalive():
child.terminate(force=True)
assert "timeout >1.0s" in result
assert "fail" in result


def test_is_debugging(monkeypatch):
import pytest_timeout

Expand Down

0 comments on commit 6c3a5b4

Please sign in to comment.