diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2582e53..351ca54 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -20,7 +20,9 @@ jobs: with: python-version: ${{ matrix.python }} - name: Install dependencies - run: python -m pip install tox + run: python -m pip install tox ruff + - name: Run ruff + run: ruff check . - name: Run unit tests (via tox) # Run tox using the version of Python in `PATH` run: tox -e py diff --git a/fixtures/__init__.py b/fixtures/__init__.py index ad2e33f..f78e113 100644 --- a/fixtures/__init__.py +++ b/fixtures/__init__.py @@ -80,7 +80,7 @@ ] -from fixtures.fixture import ( +from fixtures.fixture import ( # noqa: E402 CompoundFixture, Fixture, FunctionFixture, @@ -88,7 +88,7 @@ MultipleExceptions, SetupError, ) -from fixtures._fixtures import ( +from fixtures._fixtures import ( # noqa: E402 ByteStream, DetailStream, EnvironmentVariable, @@ -114,11 +114,11 @@ WarningsCapture, WarningsFilter, ) -from fixtures.testcase import TestWithFixtures +from fixtures.testcase import TestWithFixtures # noqa: E402 def test_suite(): - import fixtures.tests + import fixtures.tests # noqa: F401 return fixtures.tests.test_suite() diff --git a/fixtures/fixture.py b/fixtures/fixture.py index fe028b5..f563e4a 100644 --- a/fixtures/fixture.py +++ b/fixtures/fixture.py @@ -194,7 +194,7 @@ def setUp(self): self._clear_cleanups() try: self._setUp() - except: + except BaseException: err = sys.exc_info() details = {} if gather_details is not None: @@ -380,12 +380,14 @@ def setUp(self): if setup is None: setup = getattr(obj, 'setUp', None) if setup is None: - setup = lambda: None + def setup(): + return None self._setup = setup if cleanup is None: cleanup = getattr(obj, 'tearDown', None) if cleanup is None: - cleanup = lambda: None + def cleanup(): + return None self._cleanup = cleanup if reset is None: reset = getattr(obj, 'reset', None) diff --git a/fixtures/tests/_fixtures/test_logger.py b/fixtures/tests/_fixtures/test_logger.py index 95703f0..8f23cff 100644 --- a/fixtures/tests/_fixtures/test_logger.py +++ b/fixtures/tests/_fixtures/test_logger.py @@ -134,7 +134,7 @@ def test_logging_output_included_in_details(self): self.assertEqual("some message\n", content.as_text()) except AssertionError: raise - except: + except BaseException: pass def test_exceptionraised(self): diff --git a/fixtures/tests/_fixtures/test_monkeypatch.py b/fixtures/tests/_fixtures/test_monkeypatch.py index 34a3ec2..8113261 100644 --- a/fixtures/tests/_fixtures/test_monkeypatch.py +++ b/fixtures/tests/_fixtures/test_monkeypatch.py @@ -113,7 +113,7 @@ def test_patch_missing_attribute(self): self.assertFalse('new_attr' in globals()) fixture.setUp() try: - self.assertEqual(True, new_attr) + self.assertEqual(True, new_attr) # noqa: F821 finally: fixture.cleanUp() self.assertFalse('new_attr' in globals())