编写测试代码时候的小错误——takes 0 positional arguments but 1 was given
来源:互联网 发布:java微信退款接口demo 编辑:程序博客网 时间:2024/06/07 01:53
import unittest
from city_functions import get_city_country
from city_functions import get_city_country
class CityFuctionTestCase(unittest.TestCase):
def test_city_country_population():
city_country_population=get_city_country('santiago','chile',5000000)self.assertEqual(city_country_population,'Santiago,Chile,population=5000000')
以上是我编写的一个测试代码,然而出现了takes 0 positional arguments but 1 was given。其根本原因是我没有在类中的函数内引入self,即标红处应该改成
def test_city_country_population(self):
这是一个很基本的,但是很严重的错误。只是因为测试类中无需写__init__()函数,所以就连self都忘记了。。。。
==============================================================================================================
在编写测试代码时候,会出现属性错误。我的问题是,在编写的被测试代码中,某个函数没有给出return的值,致使测试代码在调用这个函数进行断言时,得不到值而出现错误。
阅读全文
0 0
- 编写测试代码时候的小错误——takes 0 positional arguments but 1 was given
- takes 0 positional arguments but 1 was given
- main() takes 0 positional arguments but 1 was given
- Python 错误之函数takes 0 positional arguments but 1 was given
- Python-类-函数参数-takes 0 positional arguments but 1 was given
- Python:sql_for_inline_foreign_key_references() takes 4 positional arguments but 5 were given
- #Tensorflow# TypeError: set_shape() takes 1 positional argument but 2 were given
- PAMIE TypeError: getElementsByTagName() takes exactly 1 positional argument (2 given)
- TypeError: this constructor takes no arguments(Python 学习遇到的错误1)
- python 使用装饰器提示:TypeError: wrapper() takes no arguments (1 given)
- TypeError: __init__() takes exactly 2 arguments (1 given)(已解决)
- TypeError: playMovVideos() takes exactly 2 arument but 3 to given的解决方法
- MonkeyRunner_TypeError: __init__() takes at least 3 arguments (2 given)
- TypeError: add_or_update() takes at most 3 arguments (4 given)
- TypeError: print_space() takes exactly 2 arguments (3 given)
- TypeError: distinct() takes exactly 2 arguments (3 given)
- TypeError: __init__() takes exactly 2 arguments (3 given)
- TypeError: __init__() takes at least 4 arguments (4 given)
- UI与Handler
- C++模板函数 & 模板类
- AS3.0多渠道打包解决Error:All flavors must now belong to a named flavor dimension. Learn more at https://d.a
- 常用linux命令行命令
- 项目调试debug时,出现source not found
- 编写测试代码时候的小错误——takes 0 positional arguments but 1 was given
- Object Detection入门
- 成功移植 SSH 服务到 ARM 开发板上
- Shiro并发登录人数控制-后面登录的踢出前面登录的!
- Hadoop简介与Hadoop-2.8.1 编译
- ROS多机通信/在多台机器上使用ROS系统/多台电脑使用同一个主节点ROS master/ROS多机ssh通信
- okhttp框架解析
- Vim实用技巧高清完整版PDF中文
- 使用Harr级联分类器检测人脸(包括眼睛)