def test_valid_style_is_pretty(): """If style is valid, the output should be parsed by pretty_results.""" with pytest.raises(SystemExit): with patch.object(cmdline, "pretty_results") as pretty: cmdline_exit([], {"style": 2}) assert pretty.called
def test_stacked_is_called_when_flat(): """If --flat is used the print_stacked function should be called.""" sys.argv.extend(["--flat", "hi", "fake"]) with patch.object(cmdline, "stacked_results") as stack_patch: with pytest.raises(SystemExit): cmdline_exit(["fake"], {"stacked": True}) stack_patch.assert_called_once_with(["fake"], {"stacked": True})
def test_invalid_style_is_csv(): """If the user supplies an invalid style int, should default to CSV.""" # <= py2.6 doesn't like multi-with statements with pytest.raises(SystemExit): with patch.object(cmdline, "csv_results") as csv: cmdline_exit([], {"style": 1234}) assert csv.called