parent
							
								
									6383b53ad9
								
							
						
					
					
						commit
						7ee3dd1cb5
					
				|  | @ -116,7 +116,8 @@ | ||||||
|   Example '-o xfail_strict=True'. A complete ini-options can be viewed |   Example '-o xfail_strict=True'. A complete ini-options can be viewed | ||||||
|   by py.test --help. Thanks `@blueyed`_ and `@fengxx`_ for the PR |   by py.test --help. Thanks `@blueyed`_ and `@fengxx`_ for the PR | ||||||
| 
 | 
 | ||||||
| * | * Allow passing a custom debugger class (e.g. ``IPython.core.debugger:Pdb`` | ||||||
|  |   via ``--pdbcls``).  Thanks to `@anntzer`_ for the PR. | ||||||
| 
 | 
 | ||||||
| * | * | ||||||
| 
 | 
 | ||||||
|  | @ -185,8 +186,7 @@ | ||||||
|   Before, you only got exceptions later from ``argparse`` library, |   Before, you only got exceptions later from ``argparse`` library, | ||||||
|   giving no clue about the actual reason for double-added options. |   giving no clue about the actual reason for double-added options. | ||||||
| 
 | 
 | ||||||
| * Allow passing a custom debugger class (e.g. ``IPython.core.debugger:Pdb`` | * | ||||||
|   via ``--pdbcls``. |  | ||||||
| 
 | 
 | ||||||
| * | * | ||||||
| 
 | 
 | ||||||
|  | @ -266,6 +266,7 @@ | ||||||
| .. _@DRMacIver: https://github.com/DRMacIver | .. _@DRMacIver: https://github.com/DRMacIver | ||||||
| .. _@RedBeardCode: https://github.com/RedBeardCode | .. _@RedBeardCode: https://github.com/RedBeardCode | ||||||
| .. _@Vogtinator: https://github.com/Vogtinator | .. _@Vogtinator: https://github.com/Vogtinator | ||||||
|  | .. _@anntzer: https://github.com/anntzer | ||||||
| .. _@bagerard: https://github.com/bagerard | .. _@bagerard: https://github.com/bagerard | ||||||
| .. _@blueyed: https://github.com/blueyed | .. _@blueyed: https://github.com/blueyed | ||||||
| .. _@ceridwen: https://github.com/ceridwen | .. _@ceridwen: https://github.com/ceridwen | ||||||
|  |  | ||||||
|  | @ -13,7 +13,8 @@ def pytest_addoption(parser): | ||||||
|         help="start the interactive Python debugger on errors.") |         help="start the interactive Python debugger on errors.") | ||||||
|     group._addoption( |     group._addoption( | ||||||
|         '--pdbcls', dest="usepdb_cls", metavar="modulename:classname", |         '--pdbcls', dest="usepdb_cls", metavar="modulename:classname", | ||||||
|         help="start a custom interactive Python debugger on errors.") |         help="start a custom interactive Python debugger on errors. " | ||||||
|  |              "For example: --pdbcls=IPython.core.debugger:Pdb") | ||||||
| 
 | 
 | ||||||
| def pytest_namespace(): | def pytest_namespace(): | ||||||
|     return {'set_trace': pytestPDB().set_trace} |     return {'set_trace': pytestPDB().set_trace} | ||||||
|  |  | ||||||
|  | @ -311,3 +311,28 @@ class TestPDB: | ||||||
|         child.sendeof() |         child.sendeof() | ||||||
|         if child.isalive(): |         if child.isalive(): | ||||||
|             child.wait() |             child.wait() | ||||||
|  | 
 | ||||||
|  |     def test_pdb_custom_cls(self, testdir): | ||||||
|  |         called = [] | ||||||
|  | 
 | ||||||
|  |         # install dummy debugger class and track which methods were called on it | ||||||
|  |         class _CustomPdb: | ||||||
|  |             def __init__(self, *args, **kwargs): | ||||||
|  |                 called.append("init") | ||||||
|  | 
 | ||||||
|  |             def reset(self): | ||||||
|  |                 called.append("reset") | ||||||
|  | 
 | ||||||
|  |             def interaction(self, *args): | ||||||
|  |                 called.append("interaction") | ||||||
|  | 
 | ||||||
|  |         _pytest._CustomPdb = _CustomPdb | ||||||
|  | 
 | ||||||
|  |         p1 = testdir.makepyfile("""xxx """) | ||||||
|  |         result = testdir.runpytest_inprocess( | ||||||
|  |             "--pdbcls=_pytest:_CustomPdb", p1) | ||||||
|  |         result.stdout.fnmatch_lines([ | ||||||
|  |             "*NameError*xxx*", | ||||||
|  |             "*1 error*", | ||||||
|  |         ]) | ||||||
|  |         assert called == ["init", "reset", "interaction"] | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue