def test_main_error_with_empty_string(capsys): with pytest.raises(SystemExit) as excinfo: hello.main(['']) retv, = excinfo.value.args assert retv == 1 out, err = capsys.readouterr() assert out == '' assert err == "Person's name must not be empty!\n"
def main(): print("This is the test of test() in hello.py: ") hello.test() print("This is the test of main() in hello.py: ") hello.main() print("This is the test of class Hello in hello.py: ") tmp = hello.Hello() tmp.show_string() print("This is the test of class Hello via \"from hello import Hello\"") tmp = Hello() tmp.show_string()
def test_main_error_with_emptystring(capsys): assert hello.main(['']) out, err = capsys.readouterr() assert out == '' assert err == "Persons's name must not be empty\n"
def test_main(cloud_config, capsys): table_name = TABLE_NAME_FORMAT.format( random.randrange(TABLE_NAME_RANGE)) main( cloud_config.project, cloud_config.bigtable_cluster, cloud_config.bigtable_zone, table_name) out, _ = capsys.readouterr() assert re.search( re.compile(r'Creating the Hello-Bigtable-[0-9]+ table\.'), out) assert re.search(re.compile(r'Writing some greetings to the table\.'), out) assert re.search(re.compile(r'Scanning for all greetings'), out) assert re.search(re.compile(r'greeting0: Hello World!'), out) assert re.search( re.compile(r'Deleting the Hello-Bigtable-[0-9]+ table\.'), out)
def test_hello2(self): self.assertEqual(hello.main("hello2"), "Hello World2\n")
import hello import repeat hello.main() s = 'shit' exclaim = 'true' print repeat.repeat(s, exclaim) print '-' * 10
def test_main(capsys): hello.main() output, _ = capsys.readouterr() assert output == "Hello, World!\n"
from hello import square from hello import main print(square(10)) print(main(10))
def test_hello(capsys): main() captured = capsys.readouterr() assert captured.out == "Hello, instructor!\n"
def test_main(capsys): hello.main(['Joon']) out, err = capsys.readouterr() assert out == 'Hello Joon\n' assert err == ''
def setUp(self): from hello import main app = main({}) from webtest import TestApp self.testapp = TestApp(app)
def test_hello(): assert hello.main() == "Hello World!"
def test_main(capsys): hello.main(['Anthony']) out, err = capsys.readouterr() assert out == 'Hello Sexy Person Anthony\n' assert err == ''
def test_hello(self): self.assertEqual(hello.main("hello"), "Hello World\n")
def test_main(): assert main() == 2
import hello import repeat hello.main() s = 'shit' exclaim='true' print repeat.repeat(s,exclaim) print '-'*10
def test_says_world(): assert hello.main() == 0