Skip to content

Commit

Permalink
Support pytest 6.x
Browse files Browse the repository at this point in the history
pytest has removed support for pytest.Class().collect()
and we need to use from_parent.

Change-Id: Ia5fed9b22e76c99f71489283acee207f996f52a4
  • Loading branch information
zzzeek committed Sep 27, 2020
1 parent 75a8fb5 commit ffafbd4
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions lib/sqlalchemy/testing/plugin/pytestplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,10 @@ def pytest_collection_modifyitems(session, config, items):
if sub_cls is not test_class.cls:
per_cls_dict = rebuilt_items[test_class.cls]

# in pytest 5.4.0
# for inst in pytest.Class.from_parent(
# test_class.parent.parent, name=sub_cls.__name__
# ).collect():

for inst in pytest.Class(
sub_cls.__name__, parent=test_class.parent.parent
# support pytest 5.4.0 and above pytest.Class.from_parent
ctor = getattr(pytest.Class, "from_parent", pytest.Class)
for inst in ctor(
name=sub_cls.__name__, parent=test_class.parent.parent
).collect():
for t in inst.collect():
per_cls_dict[t.name].append(t)
Expand Down

0 comments on commit ffafbd4

Please sign in to comment.