def testItShouldJoin(self): s1 = reflection.ReflectedString("The quick") s2 = reflection.ReflectedString("brown fox jumped") s3 = "over the lazy dog." sp = reflection.ReflectedString(" ") assert sp.join([s1, s2, s3]) == "The quick brown fox jumped over the lazy dog."
def testItShouldReplace(self): s1 = reflection.ReflectedString( "The quick brown fox jumped over the lazy dog.") assert s1.replace( "dog", "zebra") == "The quick brown fox jumped over the lazy zebra."
def testItShouldSplit(self): s1 = reflection.ReflectedString( "The quick brown fox jumped over the lazy dog.") assert s1.split("e") == [ "Th", " quick brown fox jump", "d ov", "r th", " lazy dog." ]
def testItShouldSplitLines(self): s1 = reflection.ReflectedString( "The quick brown\nfox jumped over\nthe lazy dog.") assert s1.splitlines() == [ "The quick brown", "fox jumped over", "the lazy dog." ]
def testItShouldNotGetIndex(self): s1 = reflection.ReflectedString("word") try: s1.index("z") assert False, "expected ValueError" except ValueError: pass
def testItShouldNotRIndex(self): s1 = reflection.ReflectedString( "The quick brown fox jumped over the lazy dog.") try: s1.rindex("hippo") assert False, "expected ValueError" except ValueError: pass
def testItShouldTitle(self): s1 = reflection.ReflectedString( "The quick brown fox jumped over the lazy dog.") assert s1.title() == "The Quick Brown Fox Jumped Over The Lazy Dog."
def testItShouldSwapCase(self): s1 = reflection.ReflectedString( "The quick brown fox jumped over the lazy dog.") assert s1.swapcase() == "tHE QUICK BROWN FOX JUMPED OVER THE LAZY DOG."
def testItShouldLower(self): s1 = reflection.ReflectedString( "The quick brown fox jumped over the lazy dog.") assert s1.lower() == "the quick brown fox jumped over the lazy dog."
def testItShouldGetTheLength(self): s1 = reflection.ReflectedString("Hello, World!") assert len(s1) == 13
def testItShouldSupportFormats(self): s1 = reflection.ReflectedString("Insert {} Here...") assert s1.format("something") == "Insert something Here..."
def testItShouldEqualANativeString(self): s1 = reflection.ReflectedString("Hello") s2 = "Hello" assert s1 == s2
def testItShouldZFill(self): s1 = reflection.ReflectedString("word") assert s1.zfill(8) == "0000word"
def testItShouldRJust(self): s1 = reflection.ReflectedString("word") assert s1.rjust(10) == " word"
def testItShouldRIndex(self): s1 = reflection.ReflectedString( "The quick brown fox jumped over the lazy dog.") assert s1.rindex("e") == 34
def testItShouldNotRFind(self): s1 = reflection.ReflectedString( "The quick brown fox jumped over the lazy dog.") assert s1.rfind("hippo") == -1
def testItShouldBeUpper(self): assert reflection.ReflectedString("UPPER CASE").isupper() assert reflection.ReflectedString("SCREAMING_SNAKE_CASE").isupper()
def testItShouldPartition(self): s1 = reflection.ReflectedString( "The quick brown fox jumped over the lazy dog.") assert s1.partition("brown") == ("The quick ", "brown", " fox jumped over the lazy dog.")
def testItShouldUpper(self): s1 = reflection.ReflectedString( "The quick brown fox jumped over the lazy dog.") assert s1.upper() == "THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG."
def testItShouldRPartition(self): s1 = reflection.ReflectedString( "The quick brown fox jumped over the lazy dog.") assert s1.rpartition("e") == ("The quick brown fox jumped over th", "e", " lazy dog.")
def testItShouldShowAReflectedStringContainsANativeString(self): s1 = reflection.ReflectedString("Hello World") s2 = "Hello" assert s2 in s1
def testItShouldNotBeTitle(self): assert not reflection.ReflectedString("CamelCase").istitle() assert not reflection.ReflectedString("SCREAMING_SNAKE_CASE").istitle() assert not reflection.ReflectedString("Sentence case").istitle() assert not reflection.ReflectedString("snake_cake").istitle() assert not reflection.ReflectedString("UPPER CASE").istitle()
def testItShouldShowAReflectedStringDoesNotContainANativeString(self): s1 = reflection.ReflectedString("Hello World") s2 = "Fred" assert not s2 in s1
def testItShouldBeTitle(self): assert reflection.ReflectedString("Title Case").istitle()
def testItShouldNotEqualANativeString(self): s1 = reflection.ReflectedString("Hello") s2 = "World" assert s1 != s2
def testItShouldNotStartWith(self): s1 = reflection.ReflectedString( "The quick brown fox jumped over the lazy dog.") assert not s1.startswith("Z")
def testItShouldSupportIndexing(self): s1 = reflection.ReflectedString("Hello, World!") assert s1[2] == "l"
def testItShouldStrip(self): s1 = reflection.ReflectedString(" with whitespace ") assert s1.strip() == "with whitespace"
def testItShouldGetTheRepresentation(self): s1 = reflection.ReflectedString("Hello, World!") assert repr(s1) == repr("Hello, World!")
def testItShouldNotBeUpper(self): assert not reflection.ReflectedString("Title Case").isupper() assert not reflection.ReflectedString("CamelCase").isupper() assert not reflection.ReflectedString("Sentence case").isupper() assert not reflection.ReflectedString("snake_cake").isupper()