diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fdc836..59758b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +## [1.1.2] - 2021-04-19 +### Fixed +- Fix #18 plugin crash when test case is marked with a non-pytest.mark decorator + ## [1.1.1] - 2021-04-12 ### Fixed - Fix pytest fixture collection error on non-test modules diff --git a/pylint_pytest/utils.py b/pylint_pytest/utils.py index d3d113a..7dac65f 100644 --- a/pylint_pytest/utils.py +++ b/pylint_pytest/utils.py @@ -23,7 +23,8 @@ def _is_pytest_mark(decorator): if deco.expr.attrname == 'mark' and deco.expr.expr.name == 'pytest': return True except AttributeError: - return False + pass + return False def _is_pytest_fixture(decorator, fixture=True, yield_fixture=True): diff --git a/setup.py b/setup.py index b8435a6..ae9e869 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name='pylint-pytest', - version='1.1.1', + version='1.1.2', author='Reverb Chu', author_email='pylint-pytest@reverbc.tw', maintainer='Reverb Chu', diff --git a/tests/input/useless-pytest-mark-decorator/not_pytest_marker.py b/tests/input/useless-pytest-mark-decorator/not_pytest_marker.py new file mode 100644 index 0000000..0efad86 --- /dev/null +++ b/tests/input/useless-pytest-mark-decorator/not_pytest_marker.py @@ -0,0 +1,26 @@ +import functools +from types import SimpleNamespace + + +def noop(func): + @functools.wraps(func) + def wrapper_noop(*args, **kwargs): + return func(*args, **kwargs) + return wrapper_noop + + +PYTEST = SimpleNamespace( + MARK=SimpleNamespace( + noop=noop + ) +) + + +@noop +def test_non_pytest_marker(): + pass + + +@PYTEST.MARK.noop +def test_non_pytest_marker_attr(): + pass diff --git a/tests/test_pytest_mark_for_fixtures.py b/tests/test_pytest_mark_for_fixtures.py index 9ffd01a..2854126 100644 --- a/tests/test_pytest_mark_for_fixtures.py +++ b/tests/test_pytest_mark_for_fixtures.py @@ -25,3 +25,7 @@ def test_mark_usefixture_using_for_fixture_function(self): def test_other_marks_using_for_fixture(self): self.run_linter(enable_plugin=True) self.verify_messages(4) + + def test_not_pytest_marker(self): + self.run_linter(enable_plugin=True) + self.verify_messages(0)