pythonunit-testingpycharm

PyCharm - no tests were found?


I've been getting na error in PyCharm and I can't figure out why I'm getting it:

No tests were found

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:

screenshot of run configuration


Solution

  • In order to recognize test functions, they must be named test_. In your case, rename xyCheck to test_xyCheck :)