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 fd5abc1 commit 14a97a8
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 @@ -160,7 +168,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))

@pytest.mark.skip(reason="https://github.com/microsoft/vscode-python/issues/14023")
def test_discover_complex_doctest(self):
Expand Down Expand Up @@ -245,7 +253,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 14a97a8

Please sign in to comment.