def run_test(self, given_answer, expected_print): with patch('builtins.input', return_value=given_answer), patch( 'sys.stdout', new=StringIO()) as fake_out: testing_copy.test_func() self.assertEqual(fake_out.getvalue(), expected_print)
def test_1(self): with patch('sys.stdout', new=StringIO()) as fake_out: testing_copy.test_func() expected_print = "Day 1 - Python Print Function\nThe function is declared like this:\nprint('what to print')\n" self.assertEqual(fake_out.getvalue(), expected_print)
def test_1(self): with patch('sys.stdout', new=StringIO()) as fake_out: testing_copy.test_func() expected_print = "{'Harry': 'Exceeds Expectations', 'Ron': 'Acceptable', 'Hermione': 'Outstanding', 'Draco': 'Acceptable', 'Neville': 'Fail'}\n" self.assertEqual(fake_out.getvalue(), expected_print)
def test_1(self): with patch('sys.stdout', new=StringIO()) as fake_out: testing_copy.test_func() expected_print = 'Day 1 - String Manipulation\nString Concatenation is done with the "+" sign.\ne.g. print("Hello " + "world")\nNew lines can be created with a backslash and n.\n' self.assertEqual(fake_out.getvalue(), expected_print)
def test_1(self): with patch('sys.stdout', new=StringIO()) as fake_out: testing_copy.test_func() expected_print = "[1, 1, 4, 9, 25, 64, 169, 441, 1156, 3025]\n" self.assertEqual(fake_out.getvalue(), expected_print)