在Python中获得一个功能
我的功能可以从数据框架中获取列计数。
函数运行后,我想确保列计数与输入列计数相同。
因此,我在功能,colinput和coloutput中有两个变量。
当我在新文件中运行UNITSEST文件时,我正在插入函数(让我们称其为“ getWeight”(),
因此,从mainscript impert get
Weepaight中,我有两个列计数计算得出的两个列计数,
我如何编写一个比较colinput ==的测试的测试。 ?
coloutput
I have a function that gets the column count from a dataframe.
After the function is ran I want to ensure that the column count is the same as the input column count.
So, I have two variables inside the function, colinput and coloutput.
When I am running a unittest file in a new file, I am inporting the function (let's call it getweight()
so, from mainscript import getweight
Inside getweight I have the two column counts calculated
How can I write a test that compares colinput == coloutput?
I am getting stuck on the part of how to import those variables from the mainscript file.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将正在测试的计算分解为纯函数。确保MAIN可以导入而无需副作用(使用'__ -Main __'警卫):
main.py:
导入您感兴趣的主模块和测试属性:
unittest.py:
*未测试
Factor out the computation under test into a pure function. Make sure main is importable without side effects (use '__main__' guards):
main.py:
Import main module and test properties you are interested in:
unittest.py:
* not tested