I have created unitests using import unittest. When I want to run a specific test and I put a breakpoint then go to the console and try to eval expressions there\'s no r
I had the issue running pytests for django in the Pycharm debugger. Adding -s
as a parameter did the trick for me. As seen in the Pycharm bugreport: PY-22505 from Zach's answer.
Looks like the official fix for this bug, PY-22505, is to add the new JB_DISABLE_BUFFERING
environment variable to your unit test configurations (no value required, per screenshot), but only for 2017.1.3 or greater.
This screenshot shows adding the env var for the Defaults config, so all new configs will inherit it. You could also add this individually to already-saved Run/Debug configurations:
With that env var in place, I can now:
inspect my runtime and get the printouts (note captureStandardOutput='true'
):
...
##teamcity[testStarted timestamp='...' captureStandardOutput='true' locationHint='python</Users/zyoung/PycharmProjects/Foo/test/unit_tests>://test_distance.Foo.testMatchRatio_050' name='testMatchRatio_050' nodeId='3' parentNodeId='2']
import sys; print('Python %s on %s' % (sys.version, sys.platform))
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 12:39:47)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
>>> print(self)
testMatchRatio_050 (test_distance.Foo)
Pycharm unit test interactive debug command line doesn't work
use pytest
(Run > Edit Configurations > Defaults > Python tests > py.test > add -s to the options field------>(Additional Arguments).)
settings default run tests by pytest:
(Preferences > Tools > Python Intergrated Tools > default test runner)
Could this be because you use pycharm 2017.1 combined with a python environment that has teamcity-messages in it? That combi crashes, see https://youtrack.jetbrains.com/issue/PY-23926
Upvote that ticket if that's the case please (making an account took me 1 min).