{"id":17114701,"url":"https://github.com/not-raspberry/pytest_reorder","last_synced_at":"2025-04-13T04:07:17.135Z","repository":{"id":62584222,"uuid":"52222195","full_name":"not-raspberry/pytest_reorder","owner":"not-raspberry","description":"Reorder tests depending on their their paths and names.","archived":false,"fork":false,"pushed_at":"2018-05-31T10:35:57.000Z","size":35,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-29T11:43:04.368Z","etag":null,"topics":["pytest","python","python2","python3","reordering","testing"],"latest_commit_sha":null,"homepage":"","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/not-raspberry.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-21T18:54:09.000Z","updated_at":"2019-06-21T02:43:09.000Z","dependencies_parsed_at":"2022-11-03T21:57:59.192Z","dependency_job_id":null,"html_url":"https://github.com/not-raspberry/pytest_reorder","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/not-raspberry%2Fpytest_reorder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/not-raspberry%2Fpytest_reorder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/not-raspberry%2Fpytest_reorder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/not-raspberry%2Fpytest_reorder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/not-raspberry","download_url":"https://codeload.github.com/not-raspberry/pytest_reorder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248661705,"owners_count":21141450,"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":["pytest","python","python2","python3","reordering","testing"],"created_at":"2024-10-14T17:19:53.737Z","updated_at":"2025-04-13T04:07:17.102Z","avatar_url":"https://github.com/not-raspberry.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"pytest_reorder |status| |version| |pythons| |coverage|\n======================================================\n\n.. |status| image:: https://travis-ci.org/not-raspberry/pytest_reorder.svg?branch=master\n    :target: https://travis-ci.org/not-raspberry/pytest_reorder\n\n.. |version| image:: https://img.shields.io/pypi/v/pytest_reorder.svg?maxAge=2592000\n    :target: https://pypi.python.org/pypi/pytest-reorder\n\n.. |pythons| image:: https://img.shields.io/pypi/pyversions/pytest_reorder.svg?maxAge=2592000\n\n.. |coverage| image:: https://coveralls.io/repos/github/not-raspberry/pytest_reorder/badge.svg?branch=master\n    :target: https://coveralls.io/github/not-raspberry/pytest_reorder?branch=master\n\nReorder tests depending on their nodeids (strings of test file path plus test name plus\nparametrization, like:\n``test/test_prefix_reordering.py::test_reordering_default[test_names5-expected_test_order5]``).\n\nNormally tests are sorted alphabetically. That makes integration tests run before unit tests.\n\nWith **pytest_reorder** you can install a hook that will change the order of tests in the suite.\nBy default **pytest_reorder** will seek for *unit*, *integration* and *ui* tests and put them in\nthe following order:\n\n#. *unit*\n#. all tests with names not indicating unit, integration, nor UI tests\n#. *integration*\n#. *ui*\n\nThe default regular expressions can find unit, integration and UI tests both laid flat and **deeply\nnested**. You can also specify your custom order.\n\n\nHOWTO\n-----\n\nIt's possible to customize the ordering. To do so, you have to specify your custom tests order\nby passing a list of regular expresions that match tests' nodeids. If more than one regex matches\nsome test nodeid, the first one wins.\n\nCommand line interface\n~~~~~~~~~~~~~~~~~~~~~~\n\n**pytest_reorder** hooks in a ``--reorder`` command line option that takes zero arguments or an\nordering spec list.\n\n#. If no arguments are given, default reordering will be applied.\n#. If a list is passed, e.g. ``--reorder '(^|.*/)(test_)?unit' '*' '(^|.*/)(test_)?web'``, tests\n   are reordered to go as the matches in the list do. Regular list items are treated as Python\n   regexes. The special ``'*'`` match is required and specifies where to put tests that don't\n   match any of the regexes. A single asterisk was chosen for that because it's not a valid regular\n   expression.\n\nProgrammatic interface\n~~~~~~~~~~~~~~~~~~~~~~\n\nModify your main conftest file (e.g. ``tests/conftest.py``) to include:\n\n.. code:: python\n\n    from pytest_reorder import default_reordering_hook as pytest_collection_modifyitems  # add noqa here if you use pyflakes\n\nor specify a custom test order:\n\n.. code:: python\n\n    from pytest_reorder import make_reordering_hook\n    # Make unit tests run before 'db' tests, which run before 'web' tests. Other tests will run at\n    # the very beginning of the suite:\n    pytest_collection_modifyitems = make_reordering_hook(\n        [None, r'(^|.*/)(test_)?unit', r'(^|.*/)(test_)?db', r'(^|.*/)(test_)?web'])\n\n\nWithout pytest_reorder\n----------------------\n\nFlat:\n\n.. code::\n\n    sample_test_suites/flat/test_sample.py ...\n    sample_test_suites/flat/integration/test_some_integration.py ..\n    sample_test_suites/flat/ui/test_some_ui.py .\n    sample_test_suites/flat/unit/test_some_unit.py ..\n\n\nNested:\n\n.. code::\n\n    sample_test_suites/nested/app_1/tests/integration/test_some_integration.py ..\n    sample_test_suites/nested/app_1/tests/ui/test_some_ui.py .\n    sample_test_suites/nested/app_1/tests/unit/test_some_unit.py ..\n    sample_test_suites/nested/app_2/tests/test_sth.py ...\n    sample_test_suites/nested/app_2/tests/test_unit.py .\n\n\nWith pytest_reorder\n-------------------\n\nFlat:\n\n.. code::\n\n    sample_test_suites/flat/unit/test_some_unit.py ..\n    sample_test_suites/flat/test_sample.py ...\n    sample_test_suites/flat/integration/test_some_integration.py ..\n    sample_test_suites/flat/ui/test_some_ui.py .\n\n\nNested:\n\n.. code::\n\n    sample_test_suites/nested/app_1/tests/unit/test_some_unit.py ..\n    sample_test_suites/nested/app_2/tests/test_unit.py .\n    sample_test_suites/nested/app_2/tests/test_sth.py ...\n    sample_test_suites/nested/app_1/tests/integration/test_some_integration.py ..\n    sample_test_suites/nested/app_1/tests/ui/test_some_ui.py .\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnot-raspberry%2Fpytest_reorder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnot-raspberry%2Fpytest_reorder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnot-raspberry%2Fpytest_reorder/lists"}