From 109984c96e17f016b19ddc6e4f5570ad38e70533 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 1 Dec 2015 22:41:16 +0100 Subject: [PATCH] pylint: Check attr-defined-outside-init for tests. --- scripts/dev/run_pylint_on_tests.py | 1 - tests/unit/mainwindow/statusbar/test_progress.py | 4 +++- tests/unit/misc/test_autoupdate.py | 1 + tests/unit/utils/test_qtutils.py | 2 ++ tests/unit/utils/test_urlutils.py | 3 ++- 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/dev/run_pylint_on_tests.py b/scripts/dev/run_pylint_on_tests.py index 3e2d3d0b5..043c6db0a 100644 --- a/scripts/dev/run_pylint_on_tests.py +++ b/scripts/dev/run_pylint_on_tests.py @@ -49,7 +49,6 @@ def main(): files.append(os.path.join(dirpath, fn)) disabled = [ - 'attribute-defined-outside-init', 'redefined-outer-name', 'unused-argument', 'missing-docstring', diff --git a/tests/unit/mainwindow/statusbar/test_progress.py b/tests/unit/mainwindow/statusbar/test_progress.py index 8acbfb976..425cddcbc 100644 --- a/tests/unit/mainwindow/statusbar/test_progress.py +++ b/tests/unit/mainwindow/statusbar/test_progress.py @@ -71,7 +71,9 @@ def fake_statusbar(qtbot): vbox.addStretch() statusbar = FakeStatusBar(container) - statusbar.container = container # to make sure container isn't GCed + # to make sure container isn't GCed + # pylint: disable=attribute-defined-outside-init + statusbar.container = container vbox.addWidget(statusbar) container.show() diff --git a/tests/unit/misc/test_autoupdate.py b/tests/unit/misc/test_autoupdate.py index c8fed84e2..8c575b88d 100644 --- a/tests/unit/misc/test_autoupdate.py +++ b/tests/unit/misc/test_autoupdate.py @@ -38,6 +38,7 @@ class HTTPGetStub(httpclient.HTTPClient): def __init__(self, success=True, json=None): super().__init__() + self.url = None self._success = success if json: self._json = json diff --git a/tests/unit/utils/test_qtutils.py b/tests/unit/utils/test_qtutils.py index b03712741..6a3a99c5f 100644 --- a/tests/unit/utils/test_qtutils.py +++ b/tests/unit/utils/test_qtutils.py @@ -933,6 +933,8 @@ class TestEventLoop: loop: The EventLoop we're testing. """ + # pylint: disable=attribute-defined-outside-init + def _assert_executing(self): """Slot which gets called from timers to be sure the loop runs.""" assert self.loop._executing diff --git a/tests/unit/utils/test_urlutils.py b/tests/unit/utils/test_urlutils.py index 5496a019b..67f876ed0 100644 --- a/tests/unit/utils/test_urlutils.py +++ b/tests/unit/utils/test_urlutils.py @@ -47,7 +47,8 @@ class FakeDNS: FakeDNSAnswer = collections.namedtuple('FakeDNSAnswer', ['error']) def __init__(self): - self.reset() + self.used = False + self.answer = None def __repr__(self): return utils.get_repr(self, used=self.used, answer=self.answer)