Skip to content

Commit e31046b

Browse files
authored
Fix object sort order in tools tests (#14050)
* Fix object sort order in tools tests * rebase with main * Fix formatting
1 parent fd5abc1 commit e31046b

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

pythonFiles/tests/testing_tools/adapter/test_functional.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
import sys
1111
import unittest
1212

13-
import pytest
14-
1513
from ...__main__ import TESTING_TOOLS_ROOT
1614
from testing_tools.adapter.util import fix_path, PATH_SEP
1715

@@ -83,6 +81,15 @@ def fix_source(tests, testid, srcfile, lineno):
8381
test["source"] = fix_path("{}:{}".format(srcfile, lineno))
8482

8583

84+
def sorted_object(obj):
85+
if isinstance(obj, dict):
86+
return sorted((key, sorted_object(obj[key])) for key in obj.keys())
87+
if isinstance(obj, list):
88+
return sorted((sorted_object(x) for x in obj))
89+
else:
90+
return obj
91+
92+
8693
# Note that these tests are skipped if util.PATH_SEP is not os.path.sep.
8794
# This is because the functional tests should reflect the actual
8895
# operating environment.
@@ -141,7 +148,6 @@ def test_discover_simple(self):
141148
],
142149
)
143150

144-
@pytest.mark.skip(reason="https://github.com/microsoft/vscode-python/issues/14023")
145151
def test_discover_complex_default(self):
146152
projroot, testroot = resolve_testroot("complex")
147153
expected = self.complex(projroot)
@@ -160,9 +166,8 @@ def test_discover_complex_default(self):
160166
result[0]["tests"] = fix_test_order(result[0]["tests"])
161167

162168
self.maxDiff = None
163-
self.assertEqual(result, expected)
169+
self.assertEqual(sorted_object(result), sorted_object(expected))
164170

165-
@pytest.mark.skip(reason="https://github.com/microsoft/vscode-python/issues/14023")
166171
def test_discover_complex_doctest(self):
167172
projroot, _ = resolve_testroot("complex")
168173
expected = self.complex(projroot)
@@ -245,7 +250,7 @@ def test_discover_complex_doctest(self):
245250
result[0]["tests"] = fix_test_order(result[0]["tests"])
246251

247252
self.maxDiff = None
248-
self.assertEqual(result, expected)
253+
self.assertEqual(sorted_object(result), sorted_object(expected))
249254

250255
def test_discover_not_found(self):
251256
projroot, testroot = resolve_testroot("notests")

0 commit comments

Comments
 (0)