PyCharm 2017.1 cannot run unittests

已回答

It seems PyCharm 2017.1 cannot detect unit tests correctly and therefore cannot run them.

For example, the unit test below runs fine from the command line, but inside PyCharm it cannot find any tests in it to run. 

#!/usr/bin/env python

# from falcon import testing
import unittest


#class TestAPI(testing.TestCase):

class TestAPI(unittest.TestCase):

def setUp(self):
super().setUp()


class TestCoverage(TestAPI):

def test_first(self):
self.assertTrue(1 == 1)

def test_second(self):
self.assertFalse(1 == 1)

if __name__ == '__main__':
unittest.main()


Output inside PyCharm's "Run Unittests in test-foobar.py" window:

/Users/hoylen/Documents/mypoject/venv/bin/python /Applications/PyCharm.app/Contents/helpers/pycharm/_jb_unittest_runner.py --path /Users/hoylen/Documents/myproject/test-foobar.py
Testing started at 10:24 AM ...
Launching unittests with arguments python -m unittest discover -s /Users/hoylen/Documents/QCIF/devel/wick -p test-foobar.py


Ran 0 tests in 0.000s

OK

Process finished with exit code 0
Empty test suite.

5
正式评论

Hi! The problem is in hyphen inside the filename, I created a ticket: https://youtrack.jetbrains.com/issue/PY-23549

Meanwhile I would definitely recommend to use underscore instead. I believe hyphen inside a file name is a PEP8 violation.

Avatar
Permanently deleted user

Yes, that fixed the problem. The problem was caused by having hyphens in the filenames.

Thank you.

0

请先登录再写评论。