Skip to content

Commit

Permalink
Fixed compatibility with pytest 4+
Browse files Browse the repository at this point in the history
Fixes #401.
  • Loading branch information
agronholm committed Nov 4, 2019
1 parent af41bc5 commit 9f12391
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
'twisted': ['twisted'],
'zookeeper': ['kazoo'],
'testing': [
'pytest < 3.7',
'pytest',
'pytest-cov',
'pytest-tornado5'
],
Expand Down
30 changes: 13 additions & 17 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,27 +220,23 @@ def nested():
assert str(exc.value) == 'Cannot create a reference to a nested function'

@pytest.mark.parametrize('input,expected', [
pytest.mark.skipif(sys.version_info[:2] == (3, 2),
reason="Unbound methods can't be resolved on Python 3.2")(
(DummyClass.meth, 'tests.test_util:DummyClass.meth')
),
(DummyClass.meth, 'tests.test_util:DummyClass.meth'),
(DummyClass.classmeth, 'tests.test_util:DummyClass.classmeth'),
pytest.mark.skipif(sys.version_info < (3, 3),
reason="Requires __qualname__ (Python 3.3+)")(
(DummyClass.InnerDummyClass.innerclassmeth,
'tests.test_util:DummyClass.InnerDummyClass.innerclassmeth')
),
pytest.mark.skipif(sys.version_info < (3, 3),
reason="Requires __qualname__ (Python 3.3+)")(
(DummyClass.staticmeth, 'tests.test_util:DummyClass.staticmeth')
pytest.param(
DummyClass.InnerDummyClass.innerclassmeth,
'tests.test_util:DummyClass.InnerDummyClass.innerclassmeth',
marks=[pytest.mark.skipif(sys.version_info < (3, 3),
reason="Requires __qualname__ (Python 3.3+)")]
),
pytest.mark.skipif(sys.version_info >= (3, 2),
reason="Unbound methods (Python 3.2) and __qualname__ (Python 3.3+)")(
(InheritedDummyClass.pause, 'tests.test_util:InheritedDummyClass.pause')
pytest.param(
DummyClass.staticmeth,
'tests.test_util:DummyClass.staticmeth',
marks=[pytest.mark.skipif(sys.version_info < (3, 3),
reason="Requires __qualname__ (Python 3.3+)")]
),
(timedelta, 'datetime:timedelta'),
], ids=['unbound method', 'class method', 'inner class method', 'static method',
'inherited class method', 'timedelta'])
], ids=['class method', 'inner class method', 'static method', 'inherited class method',
'timedelta'])
def test_valid_refs(self, input, expected):
assert obj_to_ref(input) == expected

Expand Down

0 comments on commit 9f12391

Please sign in to comment.