Example #1
0
    def test_rand(self):
        from random import randint
        names = [["Frank", "Underwood"], ["Claire", "Underwood"],
                 ["Douglas", '"Doug"', "Stamper"], ["Zoe", "Barnes"],
                 ["Peter", "Russo"], ["Remy", "Danton"],
                 ["Former", "President", "Garrett", "Walker"]]
        cities = [
            "New York City", "Los Angeles", "Chicago", "Houston",
            "Philadelphia", "Detroit"
        ]
        states = [
            "New York", "California", "Illinois", "Texas", "Pennsylvania",
            "Michigan"
        ]
        sol = lambda name, city, state: "Hello, " + " ".join(
            name) + "! Welcome to " + city + ", " + state + "!"

        for _ in range(40):
            name = names[randint(0, len(names) - 1)]
            location = randint(0, len(cities) - 1)
            city = cities[location]
            state = states[location]
            Test.it("Testing for " + " ".join(name) + " in " + city + ", " +
                    state)
            self.assertEqual(say_hello(name, city, state),
                             sol(name, city, state),
                             "It should work for random inputs too")
Example #2
0
def test_basic_tests():
    out = 'Hello, John Smith! Welcome to Phoenix, Arizona!'
    assert say_hello(['John', 'Smith'], 'Phoenix', 'Arizona') == out

    out = 'Hello, Franklin Delano Roosevelt! Welcome to Chicago, Illinois!'
    assert say_hello(['Franklin', 'Delano', 'Roosevelt'], 'Chicago',
                     'Illinois') == out

    out = 'Hello, Wallace Russel Osbourne! Welcome to Albany, New York!'
    assert say_hello(['Wallace', 'Russel', 'Osbourne'], 'Albany', 'New York') \
        == out

    out = 'Hello, Lupin the Third! Welcome to Los Angeles, California!'
    assert say_hello(['Lupin', 'the', 'Third'], 'Los Angeles', 'California') \
        == out

    out = 'Hello, Marlo Stanfield! Welcome to Baltimore, Maryland!'
    assert say_hello(['Marlo', 'Stanfield'], 'Baltimore', 'Maryland') == out
Example #3
0
from say_hello import say_hello

say_hello()
Example #4
0
#!/usr/bin/env python3

import say_hello
say_hello.say_hello()
Example #5
0
def main():
    print('程序开始执行')
    print(say_hello('孙悟空'))