Pytest on Python Tools for visual studio
Asked Answered
D

2

6

Can debug python tests which are using pytest library on visual studio 2010 ? I added the -m pytest on the Interpreter arguments but the breakpoints are not hit, I can only run the test script without debugging it.

Denby answered 2/12, 2013 at 10:38 Comment(0)
P
6

Pytest recommends creating a standalone startup script.

if __name__ == '__main__':
    import pytest
    pytest.main()

This is what I do and PTVS debugging works for me.

Physicochemical answered 7/12, 2013 at 19:6 Comment(0)
H
5

It would be great if you can be more specific. When I used pytools I found it very useful and found great help at http://pytools.codeplex.com. You can check http://pytools.codeplex.com/discussions.

Also check Can I debug with python debugger when using py.test somehow? or Python Unit Testing: Automatically Running the Debugger when a test fails for help as they have asked something similar.

Hairpin answered 2/12, 2013 at 10:49 Comment(2)
Thanks for the answer fscore.I need to debug pytest tests using python tools for visual studio and not python debugger(pdb). On visual studio, on project properties->debug->interpreter arguments I added "-m pytest" so the test script will be run as "python.exe -m pytest test_scripts.py". I added the breakpoints on the test script, I run it using "start with debugging" but the breakpoints are not hit, the test is just run without debug.Denby
Re: The codeplex links. "This site, including the discussions and issues, are no longer actively monitored.". They've gone to Github, sadly.Hatband

© 2022 - 2025 — McMap. All rights reserved.