Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andrelkj/shopping
https://github.com/andrelkj/shopping
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/andrelkj/shopping
- Owner: andrelkj
- Created: 2024-06-04T03:21:43.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-06-04T05:27:21.000Z (6 months ago)
- Last Synced: 2024-06-05T04:45:42.303Z (5 months ago)
- Language: Python
- Size: 22.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Pytest
Pytest is a useful tool to run test scripts with python
## How to define test files and test cases?
Pytest standard logic is to look for any file that starts with "test" and those are considered as test files. The same conversion also works to define test cases, meaning that any defined function starting with the "test" statement will be considered as one test case.
## Methods
- assert - validation method that checks if the statement is true and throw an exception in case it is not, causing the test to fail## Running tests
- pytest - run all test cases
- pytest test_shopping_cart.py - run all test cases from the file
- pytest test_shopping_cart.py::test_can_get_total_price - run only one specific function from the file### Flags
-s - force states to print out## Fixtures
Fixtures can be used in order to provide context to test cases. It replaces repetitive function calls by defining a generic function that is passed as argument inside the test cases## Mocks
Mocks are used to mimic fake behaviors by mocking one specific condition or set of data## Documentation
- [Pytest](https://docs.pytest.org/en/8.2.x/)
- [Unit test mock](https://docs.python.org/3/library/unittest.mock.html)