def test_print_colors(input_mock, capfd): not_valid = 'Not a valid color' expected = '\n'.join(['blue', 'yellow', not_valid, 'red', not_valid, 'bye']) print_colors() output = capfd.readouterr()[0].strip() assert output == expected
def test_print_colors(input_mock, capfd): not_valid = "Not a valid color" expected = "\n".join( ["blue", "yellow", not_valid, "red", not_valid, "bye"]) print_colors() output = capfd.readouterr()[0].strip() assert output == expected
def test_print_colors(input_mock, capsys): not_valid = 'Not a valid color' expected = '\n'.join( ['blue', 'yellow', not_valid, 'red', not_valid, 'bye']) # this allows using sys.exit instead of break try: print_colors() except SystemExit: pass output = capsys.readouterr()[0].strip() assert output == expected
def test_print_colors(input_mock, capsys): not_valid = "Not a valid color" expected = "\n".join( ["blue", "yellow", not_valid, "red", not_valid, "bye"]) # this allows using sys.exit instead of break try: print_colors() except SystemExit: pass output = capsys.readouterr()[0].strip() assert output == expected
def call_print_colors(): # some people prefer sys.exit instead of break try: print_colors() except SystemExit: pass