IntelliJ / PyCharm not calling unittest setUpClass
已回答
When running unittest, the setUpClass code is not called.
But the test code get's excuted right away. When running this from the command line, the setUpClass is called.
And I've setup the python environment with 3.5 and virtualenv, I'm using the project virtualenv which works fine.
IntelliJ IDEA 2016.3.5
Build #IU-163.13906.18, built on March 6, 2017
Licensed to JetBrainsStarterKit
Subscription is active until March 31, 2017
JRE: 1.8.0_112-release-408-b6 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
class TestMyCode(unittest.TestCase):
"""Advertiser Tests"""
@classmethod
def setUpClass(cls):
''' will never be called '''
x = 123
def test_one():
''' gets called without calling setUpClass first '''
x = 12345
请先登录再写评论。
It worked ok with me on PyCharm 2016.3, macOS, Python 3.6, and unittest. Screenshot attached.
We've reworked our test runner support in 2017.1...perhaps you could try the EAP?
Also same problem with my installation.
PyCharm Community Edition 2017.1.2
Build #PC-171.4249.47, built on April 26, 2017
JRE: 1.8.0_112-release-408-b6 x86
JVM: OpenJDK Server VM by JetBrains s.r.o
Windows 7 6.1
When I execute at the command line, the setup methods are called. Only not called when running from PyCharm.
I have now got the same problem. I appreciate this is an old issue but as there any fix?
Please try upgrading to the latest. If the issue persists after the upgrade - please create a bug report on YouTrack: https://youtrack.jetbrains.com/issues/PY