【发布时间】:2010-10-27 21:32:03
【问题描述】:
鼻子单元测试框架是否可以在模块的编译阶段执行测试?
其实我想测试一下结构如下:
x = 123
# [x is used here...]
def test_x():
assert (x == 123)
del x # Deleted because I don't want to clutter the module with unnecessary attributes
nosetests 告诉我 x 未定义,因为它显然在导入模块后运行 test_x() 。有没有办法让鼻子在编译阶段执行测试,同时让模块在使用它们后释放不必要的资源?
【问题讨论】:
-
您是否担心垃圾回收不起作用?
-
@ S. Lott:如果你在我的示例中不执行“del x”,我不明白为什么 x 会通过垃圾收集被删除,因为它是它的模块的属性坐在里面。因此,我相信垃圾收集,但是,除非我弄错了,否则它不会在我的示例中起作用。没有?
标签: python unit-testing nose