Exemplo n.º 1
0
    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."
Exemplo n.º 2
0
    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."
Exemplo n.º 3
0
    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."
        ]
Exemplo n.º 4
0
    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."
        ]
Exemplo n.º 5
0
    def testItShouldNotGetIndex(self):
        s1 = reflection.ReflectedString("word")

        try:
            s1.index("z")

            assert False, "expected ValueError"
        except ValueError:
            pass
Exemplo n.º 6
0
    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
Exemplo n.º 7
0
    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."
Exemplo n.º 8
0
    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."
Exemplo n.º 9
0
    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."
Exemplo n.º 10
0
    def testItShouldGetTheLength(self):
        s1 = reflection.ReflectedString("Hello, World!")

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

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

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

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

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

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

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

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

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

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

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

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

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

        assert repr(s1) == repr("Hello, World!")
Exemplo 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()