我跑
nosetests -v --nocapture --nologcapture tests/reward/test_stuff.py
我得到了
----------------------------------------------------------------------
Ran 7 tests in 0.005s
OK
没有装饰器的测试运行正常,但我有一些夹具测试设置liike,因此没有在上面的命令中运行:
@use_fixtures(fixtures.ap_user_data, fixtures.ap_like_data, fixtures.other_reward_data)
def test_settings_are_respected(data):
"""
Tests setting takes effect
"""
res = func()
assert len(res) > 0
装饰者是:
def use_fixtures(*fixtures):
"""
Decorator for tests, abstracts the build-up required when using fixtures
"""
def real_use_fixtures(func):
def use_fixtures_inner(*args, **kwargs):
env = {}
for cls in fixtures:
name = cls.__name__
table = name[:-5] #curtails _data
env[table] = get_orm_class(table)
fixture = SQLAlchemyFixture(env=env, engine=engine, style=TrimmedNameStyle(suffix="_data"))
return fixture.with_data(*fixtures)(func)()
return use_fixtures_inner
return real_use_fixtures
我是否使用装饰器阻止测试运行我的测试?
答案 0 :(得分:0)
我不知道你的装饰师是否会导致鼻子错过测试,但是如果你用装饰器进行测试怎么办,并且移除装饰器足够长的时间以查看它是否仍然错过了?