{"id":20924464,"url":"https://github.com/ax-va/pytest-okken-2022","last_synced_at":"2026-04-21T08:02:50.493Z","repository":{"id":224196732,"uuid":"762684873","full_name":"ax-va/Pytest-Okken-2022","owner":"ax-va","description":"These pytest examples are based on the book \"Python Testing with pytest: Simple, Rapid, Effective, and Scalable\", Second Edition, written by Brian Okken and published by The Pragmatic Programmers in 2022. They also cover pytest plugins. Special attention is paid to using Coverage.py, unittest.mock, and tox with pytest.","archived":false,"fork":false,"pushed_at":"2025-05-09T09:10:12.000Z","size":2077,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-26T20:14:09.468Z","etag":null,"topics":["ax-va","coverage","plugins","pytest","python","testing","tox"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ax-va.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-02-24T12:01:31.000Z","updated_at":"2025-05-09T09:10:16.000Z","dependencies_parsed_at":"2024-04-22T10:32:30.170Z","dependency_job_id":"9a5e7a52-566a-4357-bc56-fff731c3f2fb","html_url":"https://github.com/ax-va/Pytest-Okken-2022","commit_stats":null,"previous_names":["ax-va/pytest-okken-2022"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ax-va/Pytest-Okken-2022","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ax-va%2FPytest-Okken-2022","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ax-va%2FPytest-Okken-2022/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ax-va%2FPytest-Okken-2022/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ax-va%2FPytest-Okken-2022/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ax-va","download_url":"https://codeload.github.com/ax-va/Pytest-Okken-2022/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ax-va%2FPytest-Okken-2022/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32082780,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-21T06:27:27.065Z","status":"ssl_error","status_checked_at":"2026-04-21T06:27:21.250Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["ax-va","coverage","plugins","pytest","python","testing","tox"],"created_at":"2024-11-18T20:22:25.176Z","updated_at":"2026-04-21T08:02:50.475Z","avatar_url":"https://github.com/ax-va.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Learning pytest\n\nThese **pytest** examples are based on the book *\"Python Testing with pytest: Simple, Rapid, Effective, \nand Scalable\"*, Second Edition, written by Brian Okken and published by *The Pragmatic Programmers* in 2022.\nThey also cover **pytest plugins**. Special attention is paid to using **Coverage.py**, **unittest.mock**, and **tox** with **pytest**.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"/book.jpg\" width=\"400\" /\u003e\n\u003c/p\u003e\n\nAlso see the `pytest-summary` directory for quick and easy information about **pytest** features.\nThe Python versions used in the examples are 3.10, 3.11, and 3.12. \nThe third-party packages are listed in `requirements.txt`.\n\n## Original source code\nThe link to the original source code is given on the official book's side\n\n- https://pragprog.com/titles/bopytest2/python-testing-with-pytest-second-edition/\n\nOriginal installable plugin for `15--building-plugins`\n\n- https://github.com/okken/pytest-skip-slow\n\n## Upgrade pip\n\n```unix\n$ python3 -m pip install -U pip\n```\n\n## Install using `pip`\n\nAs of Python 3.3, the build-in `venv` package created a virtual environment\n`python -m venv env_dir_name [--prompt my_proj]`.\nThe `--prompt` parameter is optional. If it is not supplied, the prompt will match the directory name.\nAs of Python 3.9, providing `--prompt .` will tell `venv` to use the parent directory as the prompt.\n\nSee also: \n\n- https://docs.python.org/3/library/venv.html\n\nCreate a virtual environment, activate it on POSIX systems, and install **pytest**\n```unix\n$ python3 -m venv my_venv\n$ source my_venv/bin/activate\n(my_venv) ...$ pip install pytest\n```\nor using `virtualenv`\n```unix\n$ python3 -m pip install virtualenv\n$ python3 -m virtualenv my_venv\n$ source my_venv/bin/activate\n(my_venv) ...$ pip install pytest\n```\nDeactivate the venv\n```unix\n(my_venv) ...$ deactivate\n```\nCreate a virtual environment, activate it on Windows systems, and install **pytest**\n```windows\n\u003epython -m venv my_venv\n\u003emy_venv\\Scripts\\activate.bat\n(my_venv) ...\u003epip install pytest\n```\nActivate in PowerShell\n```windows\n\u003emy_venv\\Scripts\\Activate.ps1\n```\n\nInstall in editable mode from the current directory\n```unix\n(venv_editable) ...$ pip install -e .\n```\n\nInstall in editable mode from a directory with optional dependencies for testing\n```unix\n(venv_editable) ...$ pip install -e \"./cards_proj_failed/[test]\"\n```\n`[test]` in the `-e` parameters refers to optional dependencies for testing given in `pyproject.toml`.\n\nOther useful commands\n```unix\n(venv) ...$ pip --version\npip 24.2 from path/to/venv/lib/python3.11/site-packages/pip (python 3.11)\n(venv) ...$ pip list\nPackage            Version\n------------------ -----------\ncachetools         5.5.0\ncards              1.0.0\ncertifi            2024.8.30\n...\n```\n\nSee also: \n\n- https://pip.pypa.io/en/stable/\n\n## Run pytest\n\nRun a test modul:\n```unix\n$ pytest 01-introduction/test_01-1--passing.py\n```\n\nRun a test modul with the `--verbose` or `-v` flag:\n```unix\n$ pytest -v 01-introduction/test_01-1--passing.py\n```\n\nRun all tests starting with `test_` or ending with `_test` in the current working directory without traceback\n```unix\n$ pytest --tb=no\n```\n\nRun tests given by their names or (sub)directories in which they are located\n```unix\n$ pytest --tb=no 01-introduction/test_01-1--passing.py 01-introduction/test_01-2--failing.py\n$ pytest --tb=no 01-introduction\n```\n\nRun only specified functions\n```unix\n$ pytest -v 01-introduction/test_01-1--passing.py::test_passing\n```\n\n## Conventions to keep your test code discoverable by pytest\n\n- `test_\u003csomething\u003e.py` or `\u003csomething\u003e_test.py` for files\n\n- `test_\u003csomething\u003e` for methods and functions\n\n- `Test\u003cSomething\u003e` for classes\n\n## Stop running tox if it runs too long\n```unix\n$ ps aux | grep tox\n$ kill \u003cid\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fax-va%2Fpytest-okken-2022","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fax-va%2Fpytest-okken-2022","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fax-va%2Fpytest-okken-2022/lists"}