Created
April 19, 2013 09:21
-
-
Save pilipolio/5419171 to your computer and use it in GitHub Desktop.
Example testing for sequence equality with unittest
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
import unittest | |
class TestSequenceFunctions(unittest.TestCase): | |
def setUp(self): | |
self.expected_iterable = [0, 1, 2] | |
def test_identical_lists(self): | |
actual_iterable = [0, 1, 2] | |
self.assertSequenceEqual(actual_iterable, self.expected_iterable) | |
def test_one_value_off_actual(self): | |
actual_iterable = [0, 4, 2] | |
self.assertSequenceEqual(actual_iterable, self.expected_iterable) | |
def test_empty_actual(self): | |
actual_iterable = [] | |
self.assertSequenceEqual(actual_iterable, self.expected_iterable) | |
def test_too_long_actual(self): | |
actual_iterable = [0, 1, 2, 3] | |
self.assertSequenceEqual(actual_iterable, self.expected_iterable) | |
if __name__ == '__main__': | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment