Skip to content

Commit

Permalink
Make tests discovery compatible with pytest 6
Browse files Browse the repository at this point in the history
The 'args' keyword for the pytest.Function.from_parent constructor was removed
with pytest 6. It was unused in pytest [1] and was always an empty tuple in
the sasmodels code.

[1] pytest-dev/pytest#7226
  • Loading branch information
llimeht committed Jan 9, 2021
1 parent c43c219 commit af56f11
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ def build_test(test, value):
if collector.istestfunction(obj, name) and is_generator(obj):
tests = []
for number, yielded in enumerate(obj()):
index, call, args = split_yielded_test(yielded, number)
index, call = split_yielded_test(yielded, number)
description = getattr(call, 'description', name+index)
test = function_test(
parent=collector, name=description, args=args, callobj=call)
parent=collector, name=description, callobj=call)
tests.append(test)
return tests

Expand All @@ -74,13 +74,10 @@ def is_generator(func):
def split_yielded_test(obj, number):
if not isinstance(obj, (tuple, list)):
obj = (obj,)
if not callable(obj[0]):
index = "['%s']"%obj[0]
obj = obj[1:]
else:
index = "[%d]"%number
call, args = obj[0], obj[1:]
return index, call, args
assert callable(obj[0])
index = "[%d]"%number
call = obj[0]
return index, call

USE_DOCSTRING_AS_DESCRIPTION = True
def pytest_collection_modifyitems(session, config, items):
Expand Down

0 comments on commit af56f11

Please sign in to comment.