Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/seungjaeryanlee/wrong
Evaluate your unit test skills
https://github.com/seungjaeryanlee/wrong
Last synced: 2 days ago
JSON representation
Evaluate your unit test skills
- Host: GitHub
- URL: https://github.com/seungjaeryanlee/wrong
- Owner: seungjaeryanlee
- License: mit
- Created: 2018-06-13T09:50:11.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-06-14T04:18:31.000Z (over 6 years ago)
- Last Synced: 2024-09-05T10:41:52.404Z (5 months ago)
- Language: Python
- Homepage: https://pypi.org/project/wrong/
- Size: 6.84 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# wrong
Evaluate your unit test skills
## Installation
You can install `wrong` through Python Package Index (PyPI):
```
pip install wrong
```## Example with pytest
To evaluate your unit test skills, first write test functions for any of the modules in `wrong`. (We chose `wrong.sort` here) Then, import `sort` and run your test.
```
from wrong import sortdef test_sort_sorted():
a = [1, 2, 3, 4]
answer = [1, 2, 3, 4]
sort(a)
assert a == answerdef test_sort_unsorted():
a = [1, 4, 2, 3]
answer = [1, 2, 3, 4]
sort(a)
assert a == answer
```If some of your unit tests fail, try testing with other implementations of sort with `wrong.importer(module_name, function_id).`
```
import wrongsort = wrong.importer('sort', 0)
def test_sort_sorted():
a = [1, 2, 3, 4]
answer = [1, 2, 3, 4]
sort(a)
assert a == answerdef test_sort_unsorted():
a = [1, 4, 2, 3]
answer = [1, 2, 3, 4]
sort(a)
assert a == answer
````sort` has 1 correct implementation with id 0, and 4 incorrect implementations with ids 1, 2, 3, 4. If your tests pass for all correct implementations and fail for all incorrect implementations, your unit tests are working as intended!