鼻子单元测试框架是否可以在模块的编译阶段执行测试?
事实上,我想用以下结构测试一些东西:
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() 。有没有办法在编译阶段让鼻子执行测试,同时让模块在使用它们后释放不必要的资源?