Created
October 11, 2018 01:46
-
-
Save jfthuong/8b8af5e1311b170db4f0cda50fc167f8 to your computer and use it in GitHub Desktop.
Test of Solution for WPE Week 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import solution | |
import pytest | |
list_test_inputs = [ | |
(10,), | |
(10, 20), | |
(20, 10), | |
(10, 20, 2), | |
(10, 10, 2), # start = stop | |
(10, 20, -1), # empty list | |
(20, 10, -1), # decreasing order | |
(10, 20, 3), | |
] | |
list_test_null = [(10, 20, 0), (10, 10, 0)] | |
def test_myrange2_is_a_list(): | |
output = solution.myrange2(10) | |
assert type(output) is list | |
@pytest.mark.parametrize("inputs", list_test_inputs) | |
def test_myrange2(inputs): | |
expected = list(range(*inputs)) | |
assert solution.myrange2(*inputs) == expected | |
@pytest.mark.parametrize("inputs", list_test_null) | |
def test_myrange2_null(inputs): | |
with pytest.raises(ValueError): | |
solution.myrange2(*inputs) | |
def test_myrange3_is_a_generator(): | |
output = solution.myrange3(10) | |
assert iter(output) is output | |
@pytest.mark.parametrize("inputs", list_test_inputs) | |
def test_myrange3(inputs): | |
expected = list(range(*inputs)) | |
assert list(solution.myrange3(*inputs)) == expected | |
@pytest.mark.parametrize("inputs", list_test_null) | |
def test_myrange3_null(inputs): | |
with pytest.raises(ValueError): | |
solution.myrange3(*inputs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment