PyCharm - no tests were found?

2024/11/20 8:30:10

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 ossys.path.insert(0, os.path.abspath('..'))from ..point import Pointclass TestPoint(unittest.TestCase):def setUp(self):passdef 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 unittestfrom .utils import check_coincident, shift_pointclass Point(object):def __init__(self,x,y,mark={}):self.x = xself.y = yself.mark = markdef 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

Answer

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

https://en.xdnf.cn/q/26346.html

Related Q&A

Does Python PIL resize maintain the aspect ratio?

Does PIL resize to the exact dimensions I give it no matter what? Or will it try to keep the aspect ratio if I give it something like the Image.ANTIALIAS argument?

How to scale images to screen size in Pygame

I was wondering how I would go about scaling the size of images in pygame projects to the resolution of the screen. For example, envisage the following scenario assuming windowed display mode for the t…

GridSearch for an estimator inside a OneVsRestClassifier

I want to perform GridSearchCV in a SVC model, but that uses the one-vs-all strategy. For the latter part, I can just do this:model_to_set = OneVsRestClassifier(SVC(kernel="poly"))My problem …

The Pythonic way of organizing modules and packages

I come from a background where I normally create one file per class. I organize common classes under directories as well. This practice is intuitive to me and it has been proven to be effective in C++,…

Where do you need to use lit() in Pyspark SQL?

Im trying to make sense of where you need to use a lit value, which is defined as a literal column in the documentation.Take for example this udf, which returns the index of a SQL column array:def find…

Evaluate multiple scores on sklearn cross_val_score

Im trying to evaluate multiple machine learning algorithms with sklearn for a couple of metrics (accuracy, recall, precision and maybe more).For what I understood from the documentation here and from t…

Generate SQL statements from a Pandas Dataframe

I am loading data from various sources (csv, xls, json etc...) into Pandas dataframes and I would like to generate statements to create and fill a SQL database with this data. Does anyone know of a way…

How to translate a model label in Django Admin?

I could translate Django Admin except a model label because I dont know how to translate a model label in Django Admin. So, how can I translate a model label in Django Admin?

converty numpy array of arrays to 2d array

I have a pandas series features that has the following values (features.values)array([array([0, 0, 0, ..., 0, 0, 0]), array([0, 0, 0, ..., 0, 0, 0]),array([0, 0, 0, ..., 0, 0, 0]), ...,array([0, 0, 0, …

profiling a method of a class in Python using cProfile?

Id like to profile a method of a function in Python, using cProfile. I tried the following:import cProfile as profile# Inside the class method... profile.run("self.myMethod()", "output_f…