Created
August 2, 2018 15:00
-
-
Save benhowes/a589e0b3b0a30a3e047a4b125d5a48cc to your computer and use it in GitHub Desktop.
This file contains 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
# Unittest style, written for easy port | |
def test_boolean_validator(self): | |
variations = ( | |
('False', 'err'), | |
('True', 'err'), | |
(0, 'err'), | |
(1, 'err'), | |
(True, True), | |
(False, False), | |
({}, 'err'), | |
((,), 'err') | |
) | |
for (claim_value, expected) in variations: | |
if expected == "err": | |
with self.expectRaises(TypeError): | |
boolean_parser(claim_value) | |
else: | |
self.assertEqual(boolean_parser(claim_value), expected) | |
# Pytest style | |
@pytest.mark.parameterize(('claim_value,expected'), ( | |
('False', 'err'), | |
('True', 'err'), | |
(0, 'err'), | |
(1, 'err'), | |
(True, True), | |
(False, False), | |
({}, 'err'), | |
((,), 'err') | |
)) | |
def test_boolean_validator(claim_value, expected): | |
if expected == "err": | |
with pytest.raises(TypeError): | |
boolean_parser(claim_value) | |
else: | |
assert boolean_parser(claim_value) == expected |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment