cool-easter-32542
10/04/2023, 12:01 PMipdb is importable, and PYTHONBREAKPOINT is exported as 'ipdb.set_trace', yet pdb is still being used instead of ipdb.
def test_example():
breakpoint()
assert True
(3.11.4) ➜ pants test --debug test_example.py -- -s -q
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> PDB set_trace >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> /private/var/folders/yn/4q7r_wwd16v279lryh84bgtc0000gq/T/pants-sandbox-MQYs89/test_example.py(3)test_example()
-> assert True
(Pdb)
Expected Behaviour
I should get an ipdb prompt.
Currently this can only be achieved with: python -m pytest
(3.11.4) ➜ PYTHONBREAKPOINT=ipdb.set_trace python -m pytest test_example.py -s -q
> /Users/jack/code/pants-ipdb-bug/test_example.py(3)test_example()
1 def test_example():
2 breakpoint()
----> 3 assert True
ipdb>
* * *
Possible Cause
After some discussion on slack: https://pantsbuild.slack.com/archives/C046T6T9U/p1696365035778499
It's believed this is because the pytest script is calling python -sE which wipes certain variables.
After running pants export :: and activating the virtualenv this can be confirmed:
(3.11.4) ➜ head -1 $(which pytest)
#!/Users/jack/code/pants-ipdb-bug/dist/export/python/virtualenvs/python-default/3.11.4/bin/python3.11 -sE
Steps to reproduce
I have the following environment:
BUILD
python_tests(
name="root",
)
python_requirement(
name="ipdb",
requirements=["ipdb==0.13.13"],
)
python_requirement(
name="pytest",
requirements=["pytest==7.4.2"],
)
pants.toml
[GLOBAL]
pants_version = "2.17.0"
backend_packages = ["pants.backend.python"]
[python]
interpreter_constraints = ['==3.11.*']
enable_resolves = true
[python-infer]
use_rust_parser = true
[pytest]
install_from_resolve = "python-default"
requirements = [
"//:pytest",
"//:ipdb",
]
[test]
extra_env_vars = ["PYTHONBREAKPOINT=ipdb.set_trace"]
test_example.py
def test_example():
breakpoint()
assert True
Pants version
2.17.0
OS
MacOS
Additional info
N/a
pantsbuild/pants