Created
July 8, 2017 09:13
-
-
Save easonhan007/4c159e50c38e9cf75c308b8f173c785c to your computer and use it in GitHub Desktop.
This file contains hidden or 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 StringTestCase(unittest.TestCase): | |
def setUp(self): | |
self.test_string = "This is a string" | |
def testReverse(self): | |
self.assertEqual("gnirts a si sihT", self.test_string[::-1]) | |
def testSplit(self): | |
expected = ["This", "is", "a", "string"] | |
self.assertEqual(expected, self.test_string.split(" ")) | |
self.assertEqual(expected, self.test_string.split()) | |
def testLower(self): | |
self.assertEqual("this is a string", self.test_string.lower()) | |
def testUpper(self): | |
self.assertEqual("THIS IS A STRING", self.test_string.upper()) | |
def testRstrip(self): | |
string = "This is a string " | |
self.assertEqual(self.test_string, string.rstrip()) | |
def testLstrip(self): | |
string = " This is a string" | |
self.assertEqual(self.test_string, string.lstrip()) | |
def testStrip(self): | |
string = " This is a string " | |
self.assertEqual(self.test_string, string.strip()) | |
if __name__ == '__main__': | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment