Skip to content

Commit 092a87b

Browse files
committed
added incremental update of failed tests file and added setting of TESTFLO_SPEC in environment for each test
1 parent b5e729f commit 092a87b

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

testflo/filters.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
from __future__ import print_function
22

3+
import os
4+
5+
36
class TimeFilter(object):
47
"""This iterator saves to the specified output file only those tests
58
that complete successfully in max_time seconds or less. This output
@@ -29,13 +32,13 @@ def __init__(self, outfile):
2932
self.outfile = outfile
3033

3134
def get_iter(self, input_iter):
32-
fails = []
35+
try:
36+
os.remove(self.outfile)
37+
except OSError:
38+
pass
39+
3340
for result in input_iter:
3441
if result.status == 'FAIL' and not result.expected_fail:
35-
fails.append(result.spec)
42+
with open(self.outfile, 'a') as f:
43+
print(result.spec, file=f)
3644
yield result
37-
38-
if fails:
39-
with open(self.outfile, 'w') as f:
40-
for spec in sorted(fails):
41-
print(spec, file=f)

testflo/test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ def testcontext(test):
5151
global _testing_path
5252
old_sys_path = sys.path
5353

54+
os.environ['TESTFLO_SPEC'] = test.spec
55+
5456
_testing_path[0] = test.test_dir
5557
sys.path = _testing_path
5658

@@ -61,6 +63,7 @@ def testcontext(test):
6163
test.err_msg = traceback.format_exc()
6264
finally:
6365
sys.path = old_sys_path
66+
del os.environ['TESTFLO_SPEC']
6467

6568

6669
class Test(object):

0 commit comments

Comments
 (0)