Skip to content

Instantly share code, notes, and snippets.

@pilipolio
Created April 19, 2013 09:21
Show Gist options
  • Save pilipolio/5419171 to your computer and use it in GitHub Desktop.
Save pilipolio/5419171 to your computer and use it in GitHub Desktop.
Example testing for sequence equality with unittest
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