{"id":13735018,"url":"https://github.com/jparise/flake8-assertive","last_synced_at":"2025-03-15T11:33:17.415Z","repository":{"id":32429752,"uuid":"132822778","full_name":"jparise/flake8-assertive","owner":"jparise","description":"Flake8 unittest assert method checker","archived":false,"fork":false,"pushed_at":"2024-04-26T02:27:40.000Z","size":83,"stargazers_count":31,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-02T00:07:18.698Z","etag":null,"topics":["flake8","python","unittest"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/flake8-assertive/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jparise.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-09T23:20:52.000Z","updated_at":"2024-05-15T18:29:47.769Z","dependencies_parsed_at":"2023-02-17T13:02:12.180Z","dependency_job_id":"724c6ee8-0130-4770-a23c-488429fed1a7","html_url":"https://github.com/jparise/flake8-assertive","commit_stats":{"total_commits":83,"total_committers":6,"mean_commits":"13.833333333333334","dds":"0.24096385542168675","last_synced_commit":"6870fa1cdd724ad81ca9723d111d130d6032cb1b"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jparise%2Fflake8-assertive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jparise%2Fflake8-assertive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jparise%2Fflake8-assertive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jparise%2Fflake8-assertive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jparise","download_url":"https://codeload.github.com/jparise/flake8-assertive/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243725071,"owners_count":20337660,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flake8","python","unittest"],"created_at":"2024-08-03T03:01:02.151Z","updated_at":"2025-03-15T11:33:16.986Z","avatar_url":"https://github.com/jparise.png","language":"Python","funding_links":[],"categories":["Testing"],"sub_categories":[],"readme":"=================================\nFlake8 Unittest Assertion Checker\n=================================\n\n|PyPI Version| |Python Versions|\n\n``flake8-assertive`` is a `Flake8 \u003chttps://flake8.pycqa.org/\u003e`_ extension that\nencourages using richer, more specific `unittest`_ assertions beyond just the\ntypical ``assertEqual(a, b)`` and ``assertTrue(x)`` methods. The suggested\nmethods perform more precise checks and provide better failure messages than\nthe generic methods.\n\n+------------------------------------------+-----------------------------------+------+\n| Original                                 | Suggestion                        | Code |\n+==========================================+===================================+======+\n| ``assertTrue(a == b)``                   | ``assertEqual(a, b)``             | A500 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertTrue(a != b)``                   | ``assertNotEqual(a, b)``          | A500 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertFalse(a == b)``                  | ``assertNotEqual(a, b)``          | A500 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertFalse(a != b)``                  | ``assertEqual(a, b)``             | A500 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertTrue(a \u003c b)``                    | ``assertLess(a, b)``              | A500 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertTrue(a \u003c= b)``                   | ``assertLessEqual(a, b)``         | A500 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertTrue(a \u003e b)``                    | ``assertGreater(a, b)``           | A500 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertTrue(a \u003e= b)``                   | ``assertGreaterEqual(a, b)``      | A500 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertTrue(a is b)``                   | ``assertIs(a, b)``                | A501 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertTrue(a is not b)``               | ``assertIsNot(a, b)``             | A501 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertFalse(a is b)``                  | ``assertNotIs(a, b)``             | A501 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertFalse(a is not b)``              | ``assertIs(a, b)``                | A501 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertTrue(a in b)``                   | ``assertIn(a, b)``                | A501 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertTrue(a not in b)``               | ``assertNotIn(a, b)``             | A501 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertFalse(a in b)``                  | ``assertNotIn(a, b)``             | A501 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertTrue(isinstance(a, b))``         | ``assertIsInstance(a, b)``        | A501 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertFalse(isinstance(a, b))``        | ``assertNotIsInstance(a, b)``     | A501 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertEqual(a, round(b, x))``          | ``assertAlmostEqual(a, b, x)``    | A501 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertAlmostEqual(a, round(b, x))``    | ``assertAlmostEqual(a, b, x)``    | A501 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertNotEqual(a, round(b, x))``       | ``assertNotAlmostEqual(a, b, x)`` | A501 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertNotAlmostEqual(a, round(b, x))`` | ``assertNotAlmostEqual(a, b, x)`` | A501 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertEqual(a, None)``                 | ``assertIsNone(a)``               | A502 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertNotEqual(a, None)``              | ``assertIsNotNone(a)``            | A502 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertTrue(a is None)``                | ``assertIsNone(a)``               | A502 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertTrue(a is not None)``            | ``assertIsNotNone(a)``            | A502 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertFalse(a is None)``               | ``assertIsNotNone(a)``            | A502 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertFalse(a is not None)``           | ``assertIsNone(a)``               | A502 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertEqual(a, True)``                 | ``assertTrue(a)``                 | A502 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertEqual(a, False)``                | ``assertFalse(a)``                | A502 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertEquals(a, b)``                   | ``assertEqual(a, b)``             | A503 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertNotEquals(a, b)``                | ``assertNotEqual(a, b)``          | A503 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertAlmostEquals(a, b, x)``          | ``assertAlmostEqual(a, b, x)``    | A503 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertNotAlmostEquals(a, b, x)``       | ``assertNotAlmostEqual(a, b, x)`` | A503 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertTrue(a, b)``                     | ``assertTrue(a, msg=b)``          | A504 |\n+------------------------------------------+-----------------------------------+------+\n| ``assertFalse(a, b)``                    | ``assertFalse(a, msg=b)``         | A504 |\n+------------------------------------------+-----------------------------------+------+\n\nNote that some suggestions are normalized forms of the original, such as when\na double-negative is used (``assertFalse(a != b)`` → ``assertEqual(a, b)``).\nThere aren't suggestions for things like ``assertFalse(a \u003e b)``, which may or\nmay not be equivalent to ``assertLessEqual(a, b)``.\n\n\nInstallation\n------------\n\nInstall from PyPI using ``pip``:\n\n.. code-block:: sh\n\n    $ pip install flake8-assertive\n\nThe extension will be activated automatically by ``flake8``. You can verify\nthat it has been loaded by inspecting the ``flake8 --version`` string.\n\n.. code-block:: sh\n\n    $ flake8 --version\n    4.0.1 (assertive: 2.1.0, ...) CPython 3.9.10 on Darwin\n\n\nError Codes\n-----------\n\nThis extension adds three new `error codes`__ (using the ``A50`` prefix):\n\n- ``A500``: prefer *{func}* for '*{op}*' comparisons\n- ``A501``: prefer *{func}* for '*{op}*' expressions\n- ``A502``: prefer *{func}* instead of comparing to *{obj}*\n- ``A503``: use *{func}* instead of the deprecated *{name}*\n- ``A504``: prefer the 'msg=' kwarg for *{func}* diagnostics\n\n.. __: https://flake8.pycqa.org/en/latest/user/error-codes.html\n\nConfiguration\n-------------\n\nConfiguration values are specified in the ``[flake8]`` section of your `config\nfile`_ or as command line arguments (e.g. ``--assertive-snakecase``).\n\n- ``assertive-snakecase``: suggest snake_case assert method names\n  (e.g. ``assert_true()``) instead of the standard names (e.g. ``assertTrue()``)\n- ``assertive-test-pattern``: `fnmatch`_ pattern for identifying unittest test\n  files (and all other files will be skipped)\n\n.. _fnmatch: https://docs.python.org/library/fnmatch.html\n.. _unittest: https://docs.python.org/library/unittest.html\n.. _config file: https://flake8.pycqa.org/en/latest/user/configuration.html\n\nCaveats\n-------\n\nThere are some specific cases when the suggestion might not match the intent\nof the original.\n\nTesting the equality operator\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n``assertEqual()`` won't use the ``==`` operator if the comparison has been\ndelegated to a `type-specific equalilty function`__. By default, this is the\ncase for strings, sequences, lists, tuples, sets, and dicts.\n\n.. __: https://docs.python.org/3/library/unittest.html#unittest.TestCase.addTypeEqualityFunc\n\nIf your intent is to specifically test the ``==`` operator, consider writing\nthe assertion like this instead:\n\n.. code-block:: python\n\n    assertIs(a == b, True)\n\nThis approach has the benefit of verifying that the type's ``__eq__``\nimplementation returns a boolean value. Unfortunately, it also has the\ndownside of reporting the result of ``a == b`` on failure instead of the\nvalues of ``a`` and ``b``.\n\nSuggested by: `Serhiy Storchaka \u003chttps://twitter.com/SerhiyStorchaka\u003e`_\n\nAlternatives\n------------\n\n- `Teyit \u003chttps://github.com/isidentical/teyit\u003e`_ is a Python unit test formatter that\n  can perform similar assertion transformations.\n\n.. |PyPI Version| image:: https://img.shields.io/pypi/v/flake8-assertive.svg\n   :target: https://pypi.python.org/pypi/flake8-assertive\n.. |Python Versions| image:: https://img.shields.io/pypi/pyversions/flake8-assertive.svg\n   :target: https://pypi.python.org/pypi/flake8-assertive\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjparise%2Fflake8-assertive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjparise%2Fflake8-assertive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjparise%2Fflake8-assertive/lists"}