Esempio n. 1
0
def main():
    program = ["def sayHello():", "\n\tprint('Hello World!')"]
    f = open('hello.py', 'w+')
    for line in program:
        f.write(line)
    f.close()

    import hello
    hello.sayHello()
 def test_sayHello_name(self):
     result = hello.sayHello("Alex")
     self.assertEqual(result, "Hello, Alex")
Esempio n. 3
0
 def test_hello(self):
     self.assertEqual(hello.sayHello(), "Hello World!!")
Esempio n. 4
0
import hello

print hello.sayHello()

print hello.sayName("Martyn")
Esempio n. 5
0
def test_say_hello_with_input():
    # Override the Python built-in input method
    hello.input = lambda x: 'Python'
    output = hello.sayHello()
    assert 'Hello Python, nice to meet you!' == output
Esempio n. 6
0
def test_say_hello_without_input_with_mock():
    with mock.patch.object(hello, 'input', lambda x: ''):
        output = sayHello()
    assert 'Hello World' == output
Esempio n. 7
0
def test_say_hello_with_input_with_mock():
    with mock.patch.object(hello, 'input', lambda x: 'Python'):
        output = sayHello()
    assert 'Hello Python, nice to meet you!' == output
 def test_sayHello_to_nobody(self):
     with self.assertRaises(Exception):
         hello.sayHello("")
 def test_SayHello(self):
     # If the method returns "Hello World!", then the test will pass
     self.assertEqual(hello.sayHello(),"Hello World!")
Esempio n. 10
0
 def test_sayHello_without_title(self):
     result = hello.sayHello("Senko")
     self.assertEqual(result, "Hello Mr. Senko")
Esempio n. 11
0
 def test_sayHello_with_title(self):
     result = hello.sayHello("Senko", title="The Misterious")
     self.assertEqual(result, "Hello The Misterious Senko")
import hello

name = input("What is your name? ").title()
print("You have terminal cancer")
hello.sayHello(name)
print("You Gay")
hello.sayBye(name)
 def test_sayHello_to_one_person(self):
     result = hello.sayHello("Alex")
     self.assertEqual(result, "Hello, Alex")
 def test_sayHello_to_many_people(self):
     with self.assertRaises(Exception):
         hello.sayHello("Alex,Krasi")
 def test_sayHello_name_with_greeting(self):
     result = hello.sayHello("Alex", "Happy testing")
     self.assertEqual(result, "Happy testing, Alex")
Esempio n. 16
0
def test_say_hello_without_input():
    # Override the Python built-in input method
    hello.input = lambda x: ''
    output = hello.sayHello()
    assert 'Hello World' == output
Esempio n. 17
0
# test.py

import hello 

hello.sayHello()
Esempio n. 18
0
import hello
hello.sayHello()
hello.sayHello('zy')