diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2017-06-22 15:03:08 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2017-07-21 15:15:55 -0700 |
commit | a3f7113b96aa5576ee15df8155cc0d056e8efb5a (patch) | |
tree | b4ac5d2fb87d4db6d407288cbcce7d487ac093be | |
parent | fe3251bbdde4e2d2d3c3d83a23700de40ba496f7 (diff) |
framework: Fix the same bug for resume in the previous commit
The resume path duplicates the 2 lines of code, so the same fix is
required there.
Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
-rw-r--r-- | framework/backends/json.py | 5 | ||||
-rw-r--r-- | unittests/framework/backends/test_json.py | 15 |
2 files changed, 10 insertions, 10 deletions
diff --git a/framework/backends/json.py b/framework/backends/json.py index 98689cc09..dd08bf053 100644 --- a/framework/backends/json.py +++ b/framework/backends/json.py @@ -290,8 +290,9 @@ def _resume(results_dir): # Load all of the test names and added them to the test list tests_dir = os.path.join(results_dir, 'tests') - file_list = sorted(os.listdir(tests_dir), - key=lambda p: int(os.path.splitext(p)[0])) + file_list = sorted( + (l for l in os.listdir(tests_dir) if l.endswith('.json')), + key=lambda p: int(os.path.splitext(p)[0])) for file_ in file_list: with open(os.path.join(tests_dir, file_), 'r') as f: diff --git a/unittests/framework/backends/test_json.py b/unittests/framework/backends/test_json.py index 94d8fbf54..ccf445747 100644 --- a/unittests/framework/backends/test_json.py +++ b/unittests/framework/backends/test_json.py @@ -202,13 +202,11 @@ class TestResume(object): assert set(test.tests.keys()) == \ {'group1/test1', 'group1/test2', 'group2/test3'} - @pytest.mark.xfail - def test_load_invalid_folder(self, tmpdir): - """backends.json._resume: ignores invalid results""" - # XXX: I'm not sure if this test is worth fixing or not, it would - # involve a lot of code, and for this case to actually be tripped a - # user would have to write a file into the tests directory that isn't a - # number + def test_load_invalid_ext(self, tmpdir): + """backends.json._resume: ignores invalid results extensions. + + This gets triggered by an incomplete atomic write + """ f = six.text_type(tmpdir) backend = backends.json.JSONBackend(f) backend.initialize(shared.INITIAL_METADATA) @@ -218,13 +216,14 @@ class TestResume(object): t(results.TestResult('pass')) with backend.write_test("group2/test3") as t: t(results.TestResult('fail')) - with open(os.path.join(f, 'tests', 'x.json'), 'w') as w: + with open(os.path.join(f, 'tests', '3.json.tmp'), 'w') as w: w.write('foo') test = backends.json._resume(f) assert set(test.tests.keys()) == \ {'group1/test1', 'group1/test2', 'group2/test3'} + def test_load_incomplete(self, tmpdir): """backends.json._resume: loads incomplete results. |