Skip to content

Instantly share code, notes, and snippets.

@walkerdb
Created November 21, 2015 23:03
Show Gist options
  • Select an option

  • Save walkerdb/422da29aa848f5725682 to your computer and use it in GitHub Desktop.

Select an option

Save walkerdb/422da29aa848f5725682 to your computer and use it in GitHub Desktop.
import unittest # Python's testing module
from extent_splitter import split_extents # import the function we're testing
class TestExtentSplitter(unittest.TestCase):
# "setUp" is a special reserved function that is used to define any
# variables you will be using throughout the test. It runs before
# anything else in the class.
def setUp(self):
self.extent_1_raw_text = "4 linear feet and 1 oversize volume"
self.extent_1_target_output = ["4 linear feet", "1 oversize volume"]
self.extent_2_raw_text = "1 oversize volume and 5 motion picture reels"
self.extent_2_target_output = ["1 oversize volume", "5 motion picture reels"]
# Now for the tests. We will define each discrete test in its own
# function. You want to be as specific as possible when creating test
# names - this is really invaluable when figuring out exactly which
# tests are failing, and what was being tested when they failed.
# All tests need to start with "test" for the class to run properly
def test_split_first_two_element_extent_string(self):
split_extent = split_extents(self.extent_1_raw_text)
self.assertEqual(split_extent, self.extent_1_target_output)
def test_split_second_two_element_extent_string(self):
split_extent = split_extents(self.extent_2_raw_text)
self.assertEqual(split_extent, self.extent_2_target_output)
# code to have the tests run if this file is called from the command-line
if __name__ == "__main__":
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment