{"id":21044962,"url":"https://github.com/quansight/pytest-pytorch","last_synced_at":"2025-10-12T16:16:29.631Z","repository":{"id":45453639,"uuid":"356045592","full_name":"Quansight/pytest-pytorch","owner":"Quansight","description":"pytest plugin for a better developer experience when working with the PyTorch test suite","archived":false,"fork":false,"pushed_at":"2021-12-13T07:02:11.000Z","size":59,"stargazers_count":44,"open_issues_count":0,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-06-29T13:02:06.511Z","etag":null,"topics":["plugin","pytest","pytorch","torch"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Quansight.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-04-08T20:55:02.000Z","updated_at":"2024-12-13T05:56:04.000Z","dependencies_parsed_at":"2022-08-04T12:30:22.749Z","dependency_job_id":null,"html_url":"https://github.com/Quansight/pytest-pytorch","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/Quansight/pytest-pytorch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Quansight%2Fpytest-pytorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Quansight%2Fpytest-pytorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Quansight%2Fpytest-pytorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Quansight%2Fpytest-pytorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Quansight","download_url":"https://codeload.github.com/Quansight/pytest-pytorch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Quansight%2Fpytest-pytorch/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262598141,"owners_count":23334667,"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":["plugin","pytest","pytorch","torch"],"created_at":"2024-11-19T14:19:17.439Z","updated_at":"2025-10-12T16:16:24.576Z","avatar_url":"https://github.com/Quansight.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `pytest-pytorch`\n\n[![license](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause) [![repo status](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip) [![isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat\u0026labelColor=ef8336)](https://pycqa.github.io/isort/) [![black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![tests status](https://github.com/Quansight/pytest-pytorch/workflows/tests/badge.svg?branch=master)](https://github.com/Quansight/pytest-pytorch/actions?query=workflow%3Atests+branch%3Amaster)\n\n## What is it?\n\n`pytest-pytorch` is a lightweight [`pytest`]-plugin that enhances the developer experience when working with the [PyTorch] test suite if you come from a [`pytest`] background.\n\n## Why do I need it?\n\nSome testcases in the PyTorch test suite are only used as templates and will be instantiated at runtime. Unfortunately, [PyTorch]'s naming scheme for parametrizations differs from [`pytest`]'s. As a consequence, these tests cannot be selected by their names as written and one has to remember [PyTorch]'s naming scheme. This can be especially disrupting to your workflow if your IDE ([PyCharm](https://www.jetbrains.com/help/pycharm/pytest.html#run-pytest-test), [VSCode](https://code.visualstudio.com/docs/python/testing#_run-tests)) relies on [`pytest`]'s default selection syntax.\n\nIf this has ever been a source of frustration for you, worry no longer. `pytest-pytorch` was made for you.\n\n## How do I install it?\n\nYou can install `pytest-pytorch` with `pip`\n\n```shell\n$ pip install pytest-pytorch\n```\n\nor with `conda`:\n\n```shell\n$ conda install -c conda-forge pytest-pytorch\n```\n\n## How do I use it?\n\nWith `pytest-pytorch` installed you can select test cases and tests by their names as written:\n\n| Use case                            | Command                                 |\n|-------------------------------------|-----------------------------------------|\n| Run a test case against all devices | `pytest test_foo.py::TestBar`           |\n| Run a test against all devices      | `pytest test_foo.py::TestBar::test_baz` |\n\nSimilar to a parametrization by [`@pytest.mark.parametrize`](https://docs.pytest.org/en/stable/example/parametrize.html#different-options-for-test-ids) you can use the [`-k` flag](https://docs.pytest.org/en/stable/reference.html#command-line-flags) to select a specific set of parameters:\n\n| Use case                           | Command                                              |\n|------------------------------------|------------------------------------------------------|\n| Run a test case against one device | `pytest test_foo.py::TestBar -k \"$DEVICE\"`           |\n| Run a test against one device      | `pytest test_foo.py::TestBar::test_baz -k \"$DEVICE\"` |\n\n## Can I have a little more background?\n\nSure, we have written a [blog post about `pytest-pytorch`](https://labs.quansight.org/blog/2021/06/pytest-pytorch/) that goes into details.\n\n## How do I contribute?\n\nFirst and foremost: Thank you for your interest in development of `pytest-pytorch`'s! We appreciate all contributions be it code or something else. Check out our [contribution guide lines](CONTRIBUTING.md) for details.\n\n[PyTorch]: https://pytorch.org\n[`pytest`]: https://docs.pytest.org/en/stable/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquansight%2Fpytest-pytorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquansight%2Fpytest-pytorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquansight%2Fpytest-pytorch/lists"}