diff options
author | Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> | 2021-12-17 23:59:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-17 23:59:57 +0100 |
commit | ffede32040511d342272f8de31bb09c2e7b7ae2b (patch) | |
tree | 6aab9be3494f556fb7a195ffc62cdcc4ff7595fd /tests/checkers/unittest_refactoring.py | |
parent | 42e4b4bf475b4b179430deed6e4c8b38ba7965ce (diff) | |
download | pylint-git-ffede32040511d342272f8de31bb09c2e7b7ae2b.tar.gz |
Fixed extremely long processing of long lines with comma's (#5534)
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Diffstat (limited to 'tests/checkers/unittest_refactoring.py')
-rw-r--r-- | tests/checkers/unittest_refactoring.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/checkers/unittest_refactoring.py b/tests/checkers/unittest_refactoring.py index 3c87a8d33..accc4b067 100644 --- a/tests/checkers/unittest_refactoring.py +++ b/tests/checkers/unittest_refactoring.py @@ -1,9 +1,31 @@ # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html # For details: https://github.com/PyCQA/pylint/blob/main/LICENSE +import os +import signal +from contextlib import contextmanager + import astroid +import pytest from pylint.checkers.refactoring import ImplicitBooleanessChecker +from pylint.lint import Run +from pylint.reporters.text import TextReporter + +PARENT_DIR = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) +REGR_DATA = os.path.join(PARENT_DIR, "regrtest_data") + + +@contextmanager +def timeout(timeout_s: float): + def _handle(_signum, _frame): + pytest.fail("Test took too long") + + signal.signal(signal.SIGALRM, _handle) + signal.setitimer(signal.ITIMER_REAL, timeout_s) + yield + signal.setitimer(signal.ITIMER_REAL, 0) + signal.signal(signal.SIGALRM, signal.SIG_DFL) def test_class_tree_detection() -> None: @@ -46,3 +68,11 @@ class ChildClassWithoutBool(ClassWithoutBool): "dict", "object", ] + + +@pytest.mark.skipif(not hasattr(signal, "setitimer"), reason="Assumes POSIX signals") +def test_process_tokens() -> None: + with timeout(8.0): + with pytest.raises(SystemExit) as cm: + Run([os.path.join(REGR_DATA, "very_long_line.py")], reporter=TextReporter()) + assert cm.value.code == 0 |