Skip to content

Commit

Permalink
Fix object sort order in tools tests
Browse files Browse the repository at this point in the history
  • Loading branch information
karthiknadig committed Sep 23, 2020
1 parent ed0e2a7 commit d085dae
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pythonFiles/tests/testing_tools/adapter/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ def fix_source(tests, testid, srcfile, lineno):
test["source"] = fix_path("{}:{}".format(srcfile, lineno))


def sorted_object(obj):
if isinstance(obj, dict):
return sorted((key, sorted_object(obj[key])) for key in obj.keys())
if isinstance(obj, list):
return sorted((sorted_object(x) for x in obj))
else:
return obj

# Note that these tests are skipped if util.PATH_SEP is not os.path.sep.
# This is because the functional tests should reflect the actual
# operating environment.
Expand Down Expand Up @@ -159,7 +167,7 @@ def test_discover_complex_default(self):
result[0]["tests"] = fix_test_order(result[0]["tests"])

self.maxDiff = None
self.assertEqual(result, expected)
self.assertEqual(sorted_object(result), sorted_object(expected))

def test_discover_complex_doctest(self):
projroot, _ = resolve_testroot("complex")
Expand Down Expand Up @@ -243,7 +251,7 @@ def test_discover_complex_doctest(self):
result[0]["tests"] = fix_test_order(result[0]["tests"])

self.maxDiff = None
self.assertEqual(result, expected)
self.assertEqual(sorted_object(result), sorted_object(expected))

def test_discover_not_found(self):
projroot, testroot = resolve_testroot("notests")
Expand Down

0 comments on commit d085dae

Please sign in to comment.