no output in console for unittests in pycharm 2017

后端 未结 4 1897
温柔的废话
温柔的废话 2021-02-04 05:50

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

4条回答
  •  抹茶落季
    2021-02-04 06:18

    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:

    1. add a breakpoint
    2. right-click any test or class and choose the 'Debug Unittests for ...' menu option
    3. hit breakpoint, go to debug console
    4. inspect my runtime and get the printouts (note captureStandardOutput='true'):

      ...
      ##teamcity[testStarted timestamp='...' captureStandardOutput='true' locationHint='python://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)
      

提交回复
热议问题