def test__long__with_non_ascii_username(self): self.record_list[0].user = "******" tf1 = TextFormatter(self.record_list) txt = tf1.long() assert "Erdős" in txt
def test__long__should_return_a_fixed_width_string(self): tf1 = TextFormatter(self.record_list) txt = tf1.long() lengths = [len(line) for line in txt.split("\n")] self.assert_(max(lengths) <= 80)
def test__table__should_return_a_constant_width_string(self): tf1 = TextFormatter(self.record_list) txt = tf1.table() lengths = [len(line) for line in txt.split("\n")[:-1]] for l in lengths: assert l == lengths[0]
def test__format__should_raise_an_Exception_with_invalid_mode(self): tf1 = TextFormatter(self.record_list) self.assertRaises(AttributeError, tf1.format, "foo")
def test__short__should_return_a_multi_line_string(self): tf1 = TextFormatter(self.record_list) txt = tf1.short() self.assertEqual(len(txt.split("\n")), len(tf1.records))
def test__init__should_accept_an_iterable_containing_records(self): tf1 = TextFormatter(self.record_list) tf2 = TextFormatter(self.record_tuple)
def test__format__should_call_the_appropriate_method(self): tf1 = TextFormatter(self.record_list) self.assertEqual(tf1.format(mode='short'), tf1.short()) self.assertEqual(tf1.format(mode='long'), tf1.long()) self.assertEqual(tf1.format(mode='table'), tf1.table())