Skip to content

Commit

Permalink
Fix a crash when a test function is decorated with @pytest.fixture
Browse files Browse the repository at this point in the history
And astroid can't infer the name of the decorator when using ``open``
without ``with``.

Closes pylint-dev#4612
  • Loading branch information
Pierre-Sassoulas committed Jun 23, 2021
1 parent eba42d0 commit 0a884d9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ Release date: TBA
* ``setuptools_scm`` has been removed and replaced by ``tbump`` in order to not
have hidden runtime dependencies to setuptools

* Fix a crash when a test function is decorated with ``@pytest.fixture`` and astroid can't
infer the name of the decorator when using ``open`` without ``with``.

Closes #4612

* Appveyor is no longer used in the continuous integration

* Added ``deprecated-decorator``: Emitted when deprecated decorator is used.
Expand Down
3 changes: 2 additions & 1 deletion pylint/checkers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,8 +810,9 @@ def decorated_with(
decorator_node = decorator_node.func
try:
if any(
i is not None and i.qname() in qnames or i.name in qnames
i.name in qnames or i.qname() in qnames
for i in decorator_node.infer()
if i is not None and i != astroid.Uninferable
):
return True
except astroid.InferenceError:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# pylint: disable=missing-docstring,consider-using-with,redefined-outer-name

import pytest


@pytest.fixture
def qm_file():
qm_file = open("src/test/resources/example_qm_file.csv").read()
return qm_file

0 comments on commit 0a884d9

Please sign in to comment.