Commit Graph

118 Commits

Author SHA1 Message Date
Daniel Hahler 4011021823 pdb: do not raise outcomes.Exit with quit in debug 2019-03-29 11:02:34 +01:00
Daniel Hahler d53209956b test_pdb_continue_with_recursive_debug: mock pdb.set_trace 2019-03-28 11:49:01 +01:00
Daniel Hahler ae067df941 add test_pdb_continue_with_recursive_debug 2019-03-28 11:49:01 +01:00
Daniel Hahler 40718efacc Fix/revisit do_continue with regard to conditions 2019-03-28 11:49:01 +01:00
Daniel Hahler d406786a8d pdb: handle capturing with fixtures only 2019-03-28 11:49:01 +01:00
Daniel Hahler c75dd10671 pytester: testdir: set $HOME to tmpdir
This avoids loading user configuration, which might interfere with test
results, e.g. a `~/.pdbrc.py` with pdb++.

Also sets USERPROFILE, which will be required with Python 3.8 [1].

1: https://bugs.python.org/issue36264
2019-03-18 20:55:39 +01:00
Daniel Hahler 7afe17740f Merge master into features 2019-03-15 00:52:12 +01:00
Daniel Hahler bdac9d3dd0 tests: improve test_pdb_interaction_doctest
- ignore pdbrc (might be done in general, but this was the only affected
  test)
- fail faster in case of unexpected failure
2019-03-14 19:16:34 +01:00
Daniel Hahler 37158f5303 tests: fix test_pdb_interaction_continue_recursive with pdbpp 2019-03-14 19:16:34 +01:00
Daniel Hahler f7a3e001f7 pdb: allow for --pdbclass=mod:attr.class 2019-03-01 15:20:04 +01:00
Daniel Hahler a868a9ac13 pdb: validate --pdbcls option 2019-02-28 18:11:58 +01:00
Daniel Hahler 9feb4941f4 pdb: fix capturing with recursive debugging and pdb++
While I think that pdb++ should be fixed in this regard (by using
`pdb.Pdb`, and not `self.__class__` maybe), this ensures that custom
debuggers like this are working.
2019-02-11 14:52:20 +01:00
Daniel Hahler e69b1255d7 Improve quitting from pdb
Regarding tests: it merges ``test_pdb_interaction``,
``test_pdb_print_captured_stdout``, and
``test_pdb_print_captured_stderr`` into
``test_pdb_print_captured_stdout_and_stderr`` (clarity and performance,
especially since pexpect tests are slow).
2019-01-20 00:34:16 +01:00
Daniel Hahler 8152b6837e
Merge pull request #4419 from blueyed/set_trace-kwargs
pdb: support kwargs with `pdb.set_trace`
2018-12-11 04:28:24 +01:00
Ronny Pfannschmidt 7eb28f9eb7 remove yield tests and compat properties 2018-11-30 10:40:13 +01:00
Daniel Hahler 92a2884b09 pdb: support kwargs with `pdb.set_trace`
This handles `header` similar to Python 3.7 does it, and forwards any
other keyword arguments to the Pdb constructor.

This allows for `__import__("pdb").set_trace(skip=["foo.*"])`.

Fixes https://github.com/pytest-dev/pytest/issues/4416.
2018-11-19 13:04:14 +01:00
Bruno Oliveira dc20dedbc7 Change RemovedInPytest4Warnings to errors by default
To keep existing tests which emit RemovedInPytest4Warnings running, decided
to go with a command line option because:

* Is harder to integrate an ini option with tests which already use an ini file
* It also marks tests which need to be removed/updated in 4.1, when
  RemovedInPytest4Warning and related functionality are removed.

Fix #3737
2018-11-12 16:10:57 -02:00
Bruno Oliveira d1c9c54571
Merge pull request #4297 from nicoddemus/release-3.10.0
Release 3.10.0
2018-11-04 12:25:30 -03:00
Daniel Hahler e61e81a7b5 Make debugging's pytest_configure re-entrant
This is relevant when using runpytest in-process.

Fixes:

E             def test_1(testdir):
E                 testdir.runpytest()
E         >       __import__('pdb').set_trace()
E
E         ../../test_trace_after_runpytest.py:3:
E         …/Vcs/pytest/src/_pytest/debugging.py:81: in set_trace
E             tw = _pytest.config.create_terminal_writer(cls._config)
E
E         config = None, args = (), kwargs = {}, tw = <py._io.terminalwriter.TerminalWriter object at 0x7f1097088160>
E
E             def create_terminal_writer(config, *args, **kwargs):
E                 """Create a TerminalWriter instance configured according to the options
E                 in the config object. Every code which requires a TerminalWriter object
E                 and has access to a config object should use this function.
E                 """
E                 tw = py.io.TerminalWriter(*args, **kwargs)
E         >       if config.option.color == "yes":
E         E       AttributeError: 'NoneType' object has no attribute 'option'
2018-11-02 18:25:01 +01:00
Daniel Hahler e0038b82f7 pdb: improve msg about output capturing with set_trace
Do not display "IO-capturing turned off/on" when ``-s`` is used to avoid
confusion.
2018-10-31 17:09:01 +01:00
Anthony Sottile 777e9e1e17 Merge remote-tracking branch 'origin/master' into merge-master 2018-10-25 18:00:39 -07:00
Daniel Hahler ede3a4e850 pytest_{enter,leave}_pdb: pass through pdb instance 2018-10-25 13:28:24 +02:00
Daniel Hahler a4ea66cb1f pdb: resume capturing after `continue`
After `pdb.set_trace()` capturing is turned off.
This patch resumes it after using the `continue` (or `c` / `cont`)
command.

Store _pytest_capman on the class, for pdbpp's do_debug hack to keep it.

Without this, `debug …` would fail like this:

    /usr/lib/python3.6/cmd.py:217: in onecmd
        return func(arg)
    .venv/lib/python3.6/site-packages/pdb.py:608: in do_debug
        return orig_do_debug(self, arg)
    /usr/lib/python3.6/pdb.py:1099: in do_debug
        sys.call_tracing(p.run, (arg, globals, locals))
    /usr/lib/python3.6/bdb.py:434: in run
        exec(cmd, globals, locals)
    /usr/lib/python3.6/bdb.py:51: in trace_dispatch
        return self.dispatch_line(frame)
    /usr/lib/python3.6/bdb.py:69: in dispatch_line
        self.user_line(frame)
    /usr/lib/python3.6/pdb.py:261: in user_line
        self.interaction(frame, None)
    .venv/lib/python3.6/site-packages/pdb.py:203: in interaction
        self.setup(frame, traceback)
    E   AttributeError: 'PytestPdb' object has no attribute '_pytest_capman'

- add pytest_leave_pdb hook
- fixes test_pdb_interaction_capturing_twice: would fail on master now,
  but works here
2018-10-25 13:28:24 +02:00
Anthony Sottile 2368fbb63c Apply reorder-python-imports to all files 2018-10-25 00:01:29 -07:00
Bruno Oliveira b6fa4e248f
Merge pull request #4028 from asottile/revert_breakpoint_code
Revert patching of breakpointhook as it appears to do nothing
2018-10-24 17:50:19 -03:00
Daniel Hahler d6832a8b56
Merge pull request #4133 from blueyed/pdb-quit
pdb: handle quitting in post_mortem
2018-10-14 11:29:09 +02:00
Bruno Oliveira e3bf9cede4 Fix linting 2018-10-13 22:13:25 -03:00
Daniel Hahler 86c7dcff68 pdb: handle quitting in post_mortem
`help quit` in pdb says:

> Quit from the debugger. The program being executed is aborted.

But pytest would continue with the next tests, often making it necessary
to kill the pytest process when using `--pdb` and trying to cancel the
tests using `KeyboardInterrupt` / `Ctrl-C`.
2018-10-14 00:05:45 +02:00
Daniel Hahler 448830e656 Do not print INTERNALERROR with --pdb
This gets printed by the terminal reporter already, and currently
results in the same error being displayed twice, e.g. when raising an
`Exception` manually from `pytest.debugging.pytest_exception_interact`.
2018-10-13 23:56:34 +02:00
Daniel Hahler d3d8d53e41 tests: test_pdb: fix print statements 2018-10-13 23:33:52 +02:00
Bruno Oliveira 0f5263cdc3
Merge pull request #4109 from njonesu/master
Fix multiple string literals on a line #4093
2018-10-11 15:50:08 -03:00
Bruno Oliveira c9a85b0e78 Fix linting 2018-10-10 19:54:39 -03:00
Daniel Hahler be511c1a05 tests: add missing expect before sendeof for pdbpp
With pdb++ this additional `expect` is required, otherwise `sendeof()`
will block forever.
2018-10-10 20:50:49 +02:00
Daniel Hahler f36f9d2698 tests: fix/clarify expect for Pdb
`expect()` expects an regular expression, so "Pdb" is equivalent to
"(Pdb)".

But instead of escaping the parenthesis this patch removes them, to
allow for matching "(Pdb++)", too.
2018-10-10 20:50:49 +02:00
Niklas JQ c14a23d4e4 Fix #4093: multiple string literals on a line 2018-10-10 19:28:31 +02:00
Anthony Sottile 956b3aca97 Revert patching of breakpointhook as it appears to do nothing 2018-09-23 18:39:50 -07:00
Daniel Hahler e7eb7e799b logging: del item.catch_log_handler only in teardown
Without this caplog.record_tuples etc is not available anymore when using
`--pdb`.
2018-09-19 17:17:47 +02:00
Anthony Sottile 8bb8b91357 pyupgrade 1.4: tests 2018-08-22 18:47:21 -07:00
Jeffrey Rackauckas 067de257e1 Fix test_pdb.py with pexpect 2018-07-02 21:03:21 -07:00
Jeffrey Rackauckas 4a925ef5e9 Fixing bug in test. 2018-07-02 20:29:59 -07:00
Jeffrey Rackauckas 2f1a2cf07f Fixing --trace test. 2018-07-02 19:55:08 -07:00
Jeffrey Rackauckas 6cc4fe2412 Fixing bad indentation 2018-07-02 19:53:46 -07:00
Jeffrey Rackauckas 10a8691eca Add support for yielded functions. 2018-07-02 19:46:26 -07:00
Jeffrey Rackauckas bc268a58d1 Adding needed newline 2018-07-01 20:22:50 -07:00
Jeffrey Rackauckas 0b70477930 Fix linting issues. 2018-07-01 20:18:00 -07:00
Jeffrey Rackauckas 533f4cc10c Fix test to pass 2018-06-30 21:36:27 -07:00
Jeffrey Rackauckas 952bbefaac Add initial test. 2018-06-30 18:26:58 -07:00
Anthony Sottile cbaa7dd56a Upgrade pre-commit hooks except pyupgrade 2018-06-26 06:35:27 -07:00
Ronny Pfannschmidt 703e4b11ba run black 2018-05-23 16:48:46 +02:00
Bruno Oliveira 1a880be85b
Remove unused import to fix linting 2018-05-01 19:08:29 -03:00