question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sticky by default not working with pytest

See original GitHub issue

Recently I’ve noticed that when placing a debugger inside a test I am not greeted with pdbpp’s wonderful sticky mode which I have as an always on default in my pdbrc but instead I’m greeted with this:

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> PDB set_trace (IO-capturing turned off) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[39] > /Users/joshwren/REDACTED/main.py(60)get_app()
-> app = aiohttp.web.Application(
   5 frames hidden (try 'help hidden_frames')
> /Users/joshwren/REDACTED/main.py(60)

** Error in inspect.getsourcelines: 'function' object has no attribute 'endswith' **
(Pdb++)

Now this is not catastrophic as I am indeed inside my lovely python debugger of choice and if I were to use the next keyword the debugger would suddenly be in sticky mode but just one line later than I intended. I’ve localized the issue to be happening only when debugging inside pytest as my sticky by default works in any other non pytest capacity. I’ve tried googling this every few days but to no avail. Also of note is that I’ve recently switched to an m1 mac which has been full of incompatibility challenges that have been stubborn but not impossible to fix so I would not be surprised to find this to be a side effect related to apple silicon as none of my other python peers use the same cpu.

pdbpp==0.10.3 pytest==7.1.2

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:2
  • Comments:5

github_iconTop GitHub Comments

1reaction
dcmoss87commented, Jun 30, 2022

I’m also having the same issue on an M1.

0reactions
jamilraichounicommented, Sep 11, 2022

Here, it works when I call a test this way:

python -mpdb -c 'c' -m pytest --trace --pdb /path/to/my/test_module.py::my_test

and have a file ~/.pdbrc.py with the following content:

import pdb

class Config(pdb.DefaultConfig):
    sticky_by_default = True

What I’m using:

$ pip show pdbpp
Name: pdbpp
Version: 0.10.3
Summary: pdb++, a drop-in replacement for pdb
Home-page: http://github.com/antocuni/pdb
Author: Antonio Cuni
Author-email: anto.cuni@gmail.com
License: BSD
Location: /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages
Requires: fancycompleter, pygments, wmctrl
Required-by:
Read more comments on GitHub >

github_iconTop Results From Across the Web

Enter sticky mode by default with ipdb - python - Stack Overflow
Yes, from the REAMDE: put a file named .pdbrc.py in your home directory, containing: import pdb class Config(pdb.
Read more >
pytest fixtures: explicit, modular, scalable
You can think of a test as being broken down into four steps: Arrange ... function : the default scope, the fixture is...
Read more >
Feedback about --import-mode=importlib in pytest 6.0 #7245
This issue is a placeholder to gather feedback from users about the new --import-mode=importlib introduced in pytest 6.0.
Read more >
A comprehensive guide to pytest. - Level Up Coding
To share fixtures across different modules, stick them in the conftest.py file. By default, fixtures are invoked and torn down once per function...
Read more >
pytest Documentation - Read the Docs
By default, pytest will not show test durations that are too small ... However, if you are working with the import machinery yourself, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found