Skip to content

Commit

Permalink
[PyTest] Sort by test location, but not parametrization (#9353)
Browse files Browse the repository at this point in the history
A follow-up from #9188.  The
`item.location` tuple contains `(filename, line_number, test_name)`,
where the `test_name` includes a string representation of all
parameters.  This change preserves pytest's sorting of parametrized
values within a parametrized test, rather than sorting by strings.
  • Loading branch information
Lunderberg authored Oct 26, 2021
1 parent 649ee20 commit 64b58b1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion python/tvm/testing/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,13 @@ def _sort_tests(items):
Should be called from pytest_collection_modifyitems.
"""
items.sort(key=lambda item: item.location)

def sort_key(item):
filename, lineno, test_name = item.location
test_name = test_name.split("[")[0]
return filename, lineno, test_name

items.sort(key=sort_key)


def _target_to_requirement(target):
Expand Down

0 comments on commit 64b58b1

Please sign in to comment.