Пример #1
0
 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
Пример #2
0
 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)
Пример #3
0
 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]
Пример #4
0
 def test__format__should_raise_an_Exception_with_invalid_mode(self):
     tf1 = TextFormatter(self.record_list)
     self.assertRaises(AttributeError, tf1.format, "foo")
Пример #5
0
 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))
Пример #6
0
 def test__init__should_accept_an_iterable_containing_records(self):
     tf1 = TextFormatter(self.record_list)
     tf2 = TextFormatter(self.record_tuple)
Пример #7
0
 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())
Пример #8
0
 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]
Пример #9
0
 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)
Пример #10
0
 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))
Пример #11
0
 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())
Пример #12
0
 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