Beispiel #1
0
 def test_should_truncate_from_the_left_if_truncate_is_true_and_aligned_right(self):
     column = Column('name', self.length, truncate=True, align='right')
     self.assertEqual('s too long', column.format("This is too long"))
Beispiel #2
0
 def test_should_respect_a_left_alignment(self):
     column = Column('name', 5, align='left')
     self.assertEqual('25   ', column.format(25))
Beispiel #3
0
 def test_should_raise_an_error_if_truncate_is_false(self):
     value = "XX" * self.length
     with self.assertRaises(FormattedStringExceedsLengthError):
         column = Column('name', self.length)
         column.format(value)
Beispiel #4
0
 def test_should_default_to_a_string(self):
     column = Column('name', self.length)
     self.assertEqual('      Bill', column.format('Bill'))
Beispiel #5
0
 def test_should_respect_padding_with_zeros_aligned_left_with_decimal_type(self):
     column = Column('amount', 5, type=Decimal, padding='0', align='left')
     self.assertEqual('4.450', column.format(4.45))
Beispiel #6
0
 def test_should_respect_padding_with_zeros_with_integer_type(self):
     column = Column('amount', 5, padding='0', type=int)
     self.assertEqual('00025', column.format(25))
Beispiel #7
0
 def test_should_respect_padding_with_spaces(self):
     column = Column('amount', 5, padding=' ')
     self.assertEqual('   25', column.format(25))