def test_falls_back_to_generic_format_if_no_format_specified_for_warning(self): out = StringIO() warn = PrintWarnings(out, "WARNING: ") warn.example_warning(name="alice", oranges=10, bananas=20) assert_that(out.getvalue(), equal_to( "WARNING: example warning (bananas: 20, name: 'alice', oranges: 10)\n"))
def test_formats_warnings_and_prints_to_output_stream(self): out = StringIO() warn = PrintWarnings(out, "PREFIX: ", example_warning="{name} ate {apples} apples") warn.example_warning(name="bob", apples=20) assert_that(out.getvalue(), equal_to("PREFIX: bob ate 20 apples\n"))