Skip to content

Instantly share code, notes, and snippets.

@makmanalp
Created May 30, 2014 15:51
Show Gist options
  • Save makmanalp/0d2a80fb05f74c07269c to your computer and use it in GitHub Desktop.
Save makmanalp/0d2a80fb05f74c07269c to your computer and use it in GitHub Desktop.
remove_spans test cases
import unittest
def remove_spans(string, spans):
return string
class TestRemoveSpans(unittest.TestCase):
def test_one_span(self):
s = "I am a test string! Hahaaa! Narwhals!"
self.assertEquals("I am a string! Hahaaa! Narwhals!",
remove_spans(s, [(6, 11)]))
def test_two_spans(self):
s = "I am a test string! Hahaaa! Narwhals!"
self.assertEquals("I am a string! Narwhals!",
remove_spans(s, [(6, 11), (19, 27)]))
def test_empty_span(self):
s = "I am a test string! Hahaaa! Narwhals!"
self.assertEquals(s, remove_spans(s, []))
def test_consecutive_span(self):
s = "I am a test string! Hahaaa! Narwhals!"
self.assertEquals("I am a test string!",
remove_spans(s, [(19, 27), (27, 37)]))
def test_one_gap_span(self):
s = "I am a test string! Hahaaa! Narwhals!"
self.assertEquals("I am a test string!!",
remove_spans(s, [(19, 26), (27, 37)]))
def test_beginning_span(self):
s = "I am a test string! Hahaaa! Narwhals!"
self.assertEquals("a test string! Hahaaa! Narwhals!",
remove_spans(s, [(0, 5)]))
def test_end_span(self):
s = "I am a test string! Hahaaa! Narwhals!"
self.assertEquals("I am a test string! Hahaaa!",
remove_spans(s, [(27, 37)]))
if __name__ == '__main__':
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment