Download modules/pyggi/sample/Triangle_bug_python/test_triangle.py from Johnny5b/portable-ai-runner: direct link, hf CLI and curl.
- Browser
- Download file 1.19 kB
-
https://huggingface.co/datasets/Johnny5b/portable-ai-runner/resolve/main/modules/pyggi/sample/Triangle_bug_python/test_triangle.py
- Command line
-
hf download hf://datasets/Johnny5b/portable-ai-runner/modules/pyggi/sample/Triangle_bug_python/test_triangle.py
-
curl -L -o test_triangle.py https://huggingface.co/datasets/Johnny5b/portable-ai-runner/resolve/main/modules/pyggi/sample/Triangle_bug_python/test_triangle.py
1.19 kB
| import time | |
| import pytest | |
| from triangle import TriangleType, classify_triangle | |
| def check_classification(triangles, expected_result): | |
| for triangle in triangles: | |
| assert classify_triangle(*triangle) == expected_result | |
| def test_invalid_triangles(): | |
| triangles = [(1, 2, 9), (1, 9, 2), (2, 1, 9), (2, 9, 1), (9, 1, 2), | |
| (9, 2, 1), (1, 1, -1), (1, -1, 1), (-1, 1, 1)] | |
| check_classification(triangles, TriangleType.INVALID) | |
| def test_equalateral_triangles(): | |
| triangles = [(1, 1, 1), (100, 100, 100), (99, 99, 99)] | |
| check_classification(triangles, TriangleType.EQUALATERAL) | |
| def test_isoceles_triangles(): | |
| triangles = [(100, 90, 90), (90, 100, 90), (90, 90, 100), (3, 3, 2), (3, 2, 3), (2, 3, 3)] | |
| check_classification(triangles, TriangleType.ISOCELES) | |
| def test_scalene_triangles(): | |
| triangles = [(5, 4, 3), (5, 3, 4), (4, 5, 3), (4, 3, 5), (3, 5, 4)] | |
| check_classification(triangles, TriangleType.SCALENE) | |
| def starter(request): | |
| start_time = time.time() | |
| def finalizer(): | |
| print("runtime: {}".format(str(time.time() - start_time))) | |
| request.addfinalizer(finalizer) | |