I've been getting a
No tests were found
error in Pycharm and I can't figure out why I'm getting it... this is what I have for my point_test.py
:
import unittest import sys import os sys.path.insert(0, os.path.abspath('..')) from ..point import Point class TestPoint(unittest.TestCase): def setUp(self): pass def xyCheck(self,x,y): point = Point(x,y) self.assertEqual(x,point.x) self.assertEqual(y,point.y)
and this point.py
, what I'm trying to test:
import unittest from .utils import check_coincident, shift_point class Point(object): def __init__(self,x,y,mark={}): self.x = x self.y = y self.mark = mark def patched_coincident(self,point2): point1 = (self.x,self.y) return check_coincident(point1,point2) def patched_shift(self,x_shift,y_shift): point = (self.x,self.y) self.x,self,y = shift_point(point,x_shift,y_shift)
Is it something wrong with my run configuration? I looked at this SO post but I'm still utterly confused. My run configuration currently looks like this:
I guess I just understand what I could be doing wrong? Any help would be greatly appreciated, thanks!!
Check in Project settings -> Modules that you test package is marked as Tests. Right click on the test class name either in the code window or in the project panel, and select Run <classname>. If you don't see the run menu in the popup then you haven't selected a test or you don't have junit plugin installed.
In order to recognize test functions, they must be named test_
. In your case, rename xyCheck
to test_xyCheck
:)
I know it's more than a year since the question was asked, but I had the same issue and that post was the first result in search.
As I understood PyCharm (or Intellij Idea Python plugin) needs your test to meet the following criteria if you want it to be launched when you run all the tests in directory.
I'm using Intellij IDEA 2016.3.5 with Python plugin
If you want to run you tests with command line
python -m unittest
Then you should add __init__.py
to test directory. Python still wants your test function names to start with "test", and you test file name to start with "test", but in case of files it doesn't care if the first "t" is capital or not. TestCase and test_case is equally fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With