def test_keeptemp_via_env_variable():
if os.environ.get('NICEMAN_TESTS_KEEPTEMP'):
raise SkipTest("We have env variable set to preserve tempfiles")
files = []
@with_tempfile()
def check(f):
open(f, 'w').write("LOAD")
files.append(f)
with patch.dict('os.environ', {}):
check()
with patch.dict('os.environ', {'NICEMAN_TESTS_KEEPTEMP': '1'}):
check()
eq_(len(files), 2)
ok_(not exists(files[0]), msg="File %s still exists" % files[0])
ok_( exists(files[1]), msg="File %s not exists" % files[1])
rmtemp(files[-1])
评论列表
文章目录