pdb: allow for --pdbclass=mod:attr.class

This commit is contained in:
Daniel Hahler
2019-02-28 18:10:57 +01:00
parent a868a9ac13
commit f7a3e001f7
3 changed files with 38 additions and 22 deletions

View File

@@ -2,12 +2,14 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import argparse
import os
import platform
import sys
import _pytest._code
import pytest
from _pytest.debugging import _validate_usepdb_cls
try:
breakpoint
@@ -695,12 +697,15 @@ class TestPDB(object):
"*: error: argument --pdbcls: 'invalid' is not in the format 'modname:classname'"
]
)
result = testdir.runpytest_inprocess("--pdbcls=pdb:DoesNotExist")
result.stderr.fnmatch_lines(
[
"*: error: argument --pdbcls: could not get pdb class for 'pdb:DoesNotExist':*"
]
)
def test_pdb_validate_usepdb_cls(self, testdir):
assert _validate_usepdb_cls("os.path:dirname.__name__") == "dirname"
with pytest.raises(
argparse.ArgumentTypeError,
match=r"^could not get pdb class for 'pdb:DoesNotExist': .*'DoesNotExist'",
):
_validate_usepdb_cls("pdb:DoesNotExist")
def test_pdb_custom_cls_without_pdb(self, testdir, custom_pdb_calls):
p1 = testdir.makepyfile("""xxx """)