Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lulu-berlin/python-tests
Python tests (example for my dear brother)
https://github.com/lulu-berlin/python-tests
Last synced: 10 days ago
JSON representation
Python tests (example for my dear brother)
- Host: GitHub
- URL: https://github.com/lulu-berlin/python-tests
- Owner: lulu-berlin
- License: unlicense
- Created: 2018-03-18T12:55:56.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-18T12:57:25.000Z (almost 7 years ago)
- Last Synced: 2024-03-05T18:32:18.222Z (10 months ago)
- Language: Python
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# python-tests
This repository contains one module called `is_primary.py` with one function called `is_primary` that is meant to check whether a number is primary or not.
Next to it, there is a test file: `test_is_primary.py` that checks for some cases. Currently, one test out of five is "red".
To run the test, type in the shell:
```sh
python -m unittest
```This will discover all test files and run all the tests and you'll get the following message:
```
..F..
======================================================================
FAIL: test_nine (test_is_primary.TestIsPrimary)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/walter/code/python-tests/test_is_primary.py", line 20, in test_nine
self.assertFalse(is_primary(9))
AssertionError: True is not false----------------------------------------------------------------------
Ran 5 tests in 0.000s```
This means that the test that checks whether 9 is primary (it's not) failed: "True is not false".
There is a nicer way to run the test, but it requires installing one more package. Run in the shell:
```sh
sudo pip install pytest
```And then:
```sh
pytest
```And you'll get a nicer and more colorful report.
Now, all that's left is to fix the code in `is_primary.py`...