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."
Esempio n. 10
0
    def testItShouldGetTheLength(self):
        s1 = reflection.ReflectedString("Hello, World!")

        assert len(s1) == 13
Esempio n. 11
0
    def testItShouldSupportFormats(self):
        s1 = reflection.ReflectedString("Insert {} Here...")

        assert s1.format("something") == "Insert something Here..."
Esempio n. 12
0
    def testItShouldEqualANativeString(self):
        s1 = reflection.ReflectedString("Hello")
        s2 = "Hello"

        assert s1 == s2
Esempio n. 13
0
    def testItShouldZFill(self):
        s1 = reflection.ReflectedString("word")

        assert s1.zfill(8) == "0000word"
Esempio n. 14
0
    def testItShouldRJust(self):
        s1 = reflection.ReflectedString("word")

        assert s1.rjust(10) == "      word"
Esempio n. 15
0
    def testItShouldRIndex(self):
        s1 = reflection.ReflectedString(
            "The quick brown fox jumped over the lazy dog.")

        assert s1.rindex("e") == 34
Esempio n. 16
0
    def testItShouldNotRFind(self):
        s1 = reflection.ReflectedString(
            "The quick brown fox jumped over the lazy dog.")

        assert s1.rfind("hippo") == -1
Esempio n. 17
0
 def testItShouldBeUpper(self):
     assert reflection.ReflectedString("UPPER CASE").isupper()
     assert reflection.ReflectedString("SCREAMING_SNAKE_CASE").isupper()
Esempio n. 18
0
    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.")
Esempio n. 19
0
    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."
Esempio n. 20
0
    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.")
Esempio n. 21
0
    def testItShouldShowAReflectedStringContainsANativeString(self):
        s1 = reflection.ReflectedString("Hello World")
        s2 = "Hello"

        assert s2 in s1
Esempio n. 22
0
 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()
Esempio n. 23
0
    def testItShouldShowAReflectedStringDoesNotContainANativeString(self):
        s1 = reflection.ReflectedString("Hello World")
        s2 = "Fred"

        assert not s2 in s1
Esempio n. 24
0
 def testItShouldBeTitle(self):
     assert reflection.ReflectedString("Title Case").istitle()
Esempio n. 25
0
    def testItShouldNotEqualANativeString(self):
        s1 = reflection.ReflectedString("Hello")
        s2 = "World"

        assert s1 != s2
Esempio n. 26
0
    def testItShouldNotStartWith(self):
        s1 = reflection.ReflectedString(
            "The quick brown fox jumped over the lazy dog.")

        assert not s1.startswith("Z")
Esempio n. 27
0
    def testItShouldSupportIndexing(self):
        s1 = reflection.ReflectedString("Hello, World!")

        assert s1[2] == "l"
Esempio n. 28
0
    def testItShouldStrip(self):
        s1 = reflection.ReflectedString("  with whitespace  ")

        assert s1.strip() == "with whitespace"
Esempio n. 29
0
    def testItShouldGetTheRepresentation(self):
        s1 = reflection.ReflectedString("Hello, World!")

        assert repr(s1) == repr("Hello, World!")
Esempio n. 30
0
 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()