예제 #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