This repository has been archived on 2023-07-05. You can view files and clone it, but cannot push or open issues/pull-requests.
notes/Terminal Tips/Commands + Settings/Languages/Python/Projects/Testing/Testing in python.md

29 lines
732 B
Markdown
Raw Permalink Normal View History

2023-07-05 03:05:42 +00:00
# Testing functions
Once you have created your definitions you want to put them in a main class and have something to display if the functions passed. For example:
```
def test_sum():
assert sum([1, 2, 3]) == 6, "Should be 6"
def test_sum_tuple():
assert sum((1, 2, 2)) == 6, "Should be 6"
if __name__ == "__main__":
test_sum()
test_sum_tuple()
print("Everything passed")
```
This [site](https://realpython.com/python-testing/) has several differnt testing methods that can be used with python. Unittest, nose, and [pytest](https://docs.pytest.org/en/latest/) are the most commonly used.
How to execute pytest:
https://docs.pytest.org/en/latest/
## testing paradigms in python
- tox
- pytest
-