Pycharm - no tests were found?(Pycharm - 没有找到测试?)
问题描述
我得到了一个
<块引用>没有找到测试
Pycharm 中的错误,我不知道为什么我会得到它...这就是我的 point_test.py
:
导入单元测试导入系统导入操作系统sys.path.insert(0, os.path.abspath('..'))从 ..point 导入点类测试点(unittest.TestCase):定义设置(自我):经过定义 xyCheck(self,x,y):点 = 点(x,y)self.assertEqual(x,point.x)self.assertEqual(y,point.y)
还有这个 point.py
,我要测试的内容:
导入单元测试从 .utils 导入 check_coincident, shift_point类点(对象):def __init__(self,x,y,mark={}):自我.x = x自我.y = yself.mark = 标记def patched_coincident(self,point2):点 1 = (self.x,self.y)返回 check_coincident(point1,point2)def patched_shift(self,x_shift,y_shift):点 = (self.x,self.y)self.x,self,y = shift_point(point,x_shift,y_shift)
我的运行配置有问题吗?我查看了
我想我只是明白我做错了什么?任何帮助将不胜感激,谢谢!!
为了识别测试函数,必须将它们命名为test_
.在您的情况下,将 xyCheck
重命名为 test_xyCheck
:)
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!!
In order to recognize test functions, they must be named test_
. In your case, rename xyCheck
to test_xyCheck
:)
这篇关于Pycharm - 没有找到测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Pycharm - 没有找到测试?
基础教程推荐
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01
- 用于分类数据的跳跃记号标签 2022-01-01
- 线程时出现 msgbox 错误,GUI 块 2022-01-01
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01
- 筛选NumPy数组 2022-01-01
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01