def test_hello(self): stub_stdouts(self) hello_world.main() output = sys.stdout.getvalue().strip() assert "Hello" in output, \ "Program output does not include \"Hello\".\n"
def test_hello_world(self): stub_stdouts(self) hello_world.main() output = sys.stdout.getvalue().strip() assert output == "Hello World", \ "Program does not output \"Hello World\".\n" \ + "Expected: {}\n".format("Hello World") \ + "Actual: {}\n".format(output)
def main(): a = '' while a not in ('run','test'): print("Choose an option:\n\tRun\n\tTest") a = input("Your choice: ") a = a.lower() if a=="run": print("\n--Running Program--\n") student.main() elif a=="test": print("\n--Testing Program--\n") pytest.main(['-v'])
def test_hello_world(capfd): hello_world.main() out, _ = capfd.readouterr() assert out == 'Hello, World!\n'
import hello_world # Invokes methods from package hello_world.main() hello_world.sayHello()
def test_main(self): with mock.patch("sys.stdout", new_callable=io.StringIO) as stdout: expected = "Hello, World!\n" hello_world.main() self.assertEqual(stdout.getvalue(), expected)
def setUp(self): from hello_world import main app = main({}) from webtest import TestApp self.testapp = TestApp(app)
def test_main(): assert type(h.main('Hello World!')) == int
def app(app_settings): return main({}, **app_settings)