New to pyCharm - Getting started not working
I just downloaded pyCharm v1.5.4, I went to this Jetbrains video - http://tv.jetbrains.net/videocontent/getting-started-with-pycharm
This has you start by creating a project, and writing a test... pretty straight forward. However, even though my code mimics what's on the screen, I keep getting "no tests were found"
Here's the code:
from unittest import TestCase
class Conference(object):
def get_talk_at(self, time):
pass
class ConferenceTest(TestCase):
def test_empty(self):
c = Conference()
self.assertEqual(None,c.get_talk_at(10))
In the video he runs this with CTRL-SHFT-F10 (doesn't work on mine but I'd imagine that's just because which keyboard I chose) but if I go right-click the folder and select "Run Unittests in '...'" it runs, just nothing is found.
On a side note, Is there a explicit declaration I can make on a test that says "hey this is a test", kinda like NUnits [TestFixture] or [Test]? How does pycharm/python determine what methods are tests?
Please sign in to leave a comment.
Okay, changed my Keymap in the settings to "Default", came back, used the CTRL-SHFT-F10 to run the tests, and something happened (test failed, but that's a different issue). However, going to the project, right clicking the folder, and selecting "Run unitests in .." option still shows "no tests were found"
What's going on? I don't like that it's auto-magically happening with the keyboard press but not happening through the context menu... Any help would be appreciated.
UPDATE: If I right click the .py file in the folder, it runs the tests, just like the CTRL-SHFT-F10 work. Not sure why the option from the folder level doesn't work
Hi MikeM,
This happens bacause of the name of the test file.
Python unittests use "test.*" pattern to collect tests from the directory (http://docs.python.org/library/unittest.html#test-discovery).
If you want to collect tests regardless test name – just check pattern checkbox in run configuration and write ".*" as pattern.
Thanks for that.
So putting in the pattern worked, regardless of file name. I'm assuming at that point it's just looking for any class that inherits unittest.case.TestCase?
Yes, it works the same way as unittests and attaches nice tree view of results.