{"id":19164027,"url":"https://github.com/pyladiesams/pytest-aug2019","last_synced_at":"2025-09-12T18:51:39.488Z","repository":{"id":101737772,"uuid":"200914652","full_name":"pyladiesams/pytest-aug2019","owner":"pyladiesams","description":"How to use Pytest, it's best practices and how proper tests are done.","archived":false,"fork":false,"pushed_at":"2024-05-29T15:35:29.000Z","size":1753,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-07T11:39:49.328Z","etag":null,"topics":["pytest","python","testing","workshop"],"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/pyladiesams.png","metadata":{"files":{"readme":"README.md","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-08-06T19:47:18.000Z","updated_at":"2024-05-29T15:35:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"711a887b-1017-4de9-ac09-e60dd83d6ecc","html_url":"https://github.com/pyladiesams/pytest-aug2019","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pyladiesams/pytest-aug2019","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyladiesams%2Fpytest-aug2019","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyladiesams%2Fpytest-aug2019/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyladiesams%2Fpytest-aug2019/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyladiesams%2Fpytest-aug2019/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pyladiesams","download_url":"https://codeload.github.com/pyladiesams/pytest-aug2019/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyladiesams%2Fpytest-aug2019/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274859926,"owners_count":25363290,"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","status":"online","status_checked_at":"2025-09-12T02:00:09.324Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["pytest","python","testing","workshop"],"created_at":"2024-11-09T09:17:41.797Z","updated_at":"2025-09-12T18:51:39.449Z","avatar_url":"https://github.com/pyladiesams.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Project Title\r\n\r\nThis is a simple Flask application for storing and getting ToDo tasks.\r\nIt uses Flask and SQLite.  \r\nWe're going to write some tests for it.\r\n\r\n## Getting Started\r\n\r\n* Clone this repo\r\n\r\n### Prerequisites\r\n\r\nYou will need Python(I have 3.7 on my machine, but 3.5+ will work), also pip for installation packages.\r\n\r\n### Installing\r\n* If you don't have virtualenv, you should install it.\r\n```\r\npip install virtualenv\r\n```\r\n* Create a virtual environment\r\n```\r\npython -m venv name_of_your_virtual_env\r\n```\r\n* Activate it\r\n```\r\nsource name_of_your_virtual_env/bin/activate\r\n```\r\n* Add to the environment variable PYTHONPATH to direcrory with cloned repo:\r\n```\r\nexport PYTHONPATH=\"${PYTHONPATH:+/Path/to/this/repo/pytest-aug2019}\"\r\n```\r\n* Set the config environment variable:\r\n\r\n```\r\nexport APP_SETTINGS=config.py\r\n```\r\n* Install required libs in your virtual environment:\r\n```\r\npip install -r requirements.txt\r\n```\r\n\r\n## Running the tests\r\n\r\n* Go to application folder:\r\n```\r\ncd application\r\n\r\n```\r\n* Run tests all the tests:\r\n```\r\npytest\r\n\r\n```\r\n\r\n\r\n### Break down into end to end tests\r\n\r\n* e2e tests should be placed in `application/tests/tests_e2e.py`\r\n* Tests with mocked database should be placed in `application/tests/tests_db_mocked.py`\r\n\r\n## Plan for a workshop\r\n\r\n* Create a test folder and a file contftest.py. We will need to put some fixtures there.\r\n* Create a fixture for a test client.  On a set up it should create a db and start client application, on a teardown it should drop the database.\r\n* We can set scope this feature to a module.\r\n* Now create a test file and a test case for a creation a task with a particular text and date. Parametrise it.\r\n* Create a test case for getting task by id (positive and negative). Try to make it one test case using parametrisation. (Hint) We also can use pytest.raise in parameters.\r\n* Create a test case that we’ll now will fail and mark it as an xfail\r\n* (We can create more of them just to get a grip)\r\n* We kinda finished with e2e test, now we can start with mock part. Create a  folder with tests with mocks. It will need a separate conftest.py\r\n* Create a test client with mocked db part.\r\n* Create  a test case for inserting task using this client\r\n* Create a test case for getting list of tasks using this client\r\n* Let’s mark e2e test cases as e2e and run them separately\r\n* In main conftest.py create a flag for e2e tests.\r\n* Mark e2e tests with decorator for this flag.\r\n\r\n\r\n## Acknowledgments\r\n\r\n* Hat tip to anyone whose code was used\r\n* Inspiration\r\n* etc\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyladiesams%2Fpytest-aug2019","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpyladiesams%2Fpytest-aug2019","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyladiesams%2Fpytest-aug2019/lists"}