Esempio n. 1
0
    def test_format_many_mixed(self):
        class Person:
            def __init__(self, first_name: str, last_name: str):
                self.first_name = first_name
                self.last_name = last_name

            def __str__(self):
                return f'{self.first_name} {self.last_name}'

        self.assertEqual('1, two and Alice McBob',
                         nice_format((1, 'two', Person('Alice', 'McBob'))))
Esempio n. 2
0
 def test_format_two_str(self):
     self.assertEqual('Bob and Alice', nice_format(('Bob', 'Alice')))
Esempio n. 3
0
 def test_oxford_comma(self):
     self.assertEqual('1, 2, 3, and 4',
                      nice_format((1, 2, 3, 4), oxford_comma=True))
Esempio n. 4
0
 def test_format_single_str(self):
     self.assertEqual('John', nice_format(('John', )))
Esempio n. 5
0
 def test_format_many_str_no_and(self):
     self.assertEqual('1, 2, 3, 4, 5',
                      nice_format((1, 2, 3, 4, 5), use_and=False))
Esempio n. 6
0
 def test_format_single_str_no_and(self):
     self.assertEqual('1', nice_format((1, ), use_and=False))
Esempio n. 7
0
 def test_format_two_str_no_and(self):
     self.assertEqual('1, 2', nice_format((1, 2), use_and=False))
Esempio n. 8
0
 def test_format_two_int(self):
     self.assertEqual('1 and 2', nice_format((1, 2)))
Esempio n. 9
0
 def test_format_many_int(self):
     self.assertEqual('1, 2, 3, 4 and 5', nice_format((1, 2, 3, 4, 5)))
Esempio n. 10
0
 def test_format_single_int(self):
     self.assertEqual('1', nice_format((1, )))
Esempio n. 11
0
 def test_format_many_str_quote(self):
     self.assertEqual(
         '"Bob", "Alice", "Charles", "Donald" and "Eric"',
         nice_format(('Bob', 'Alice', 'Charles', 'Donald', 'Eric'),
                     string_quotes='"'))
Esempio n. 12
0
 def test_format_two_str_quote(self):
     self.assertEqual('"Bob" and "Alice"',
                      nice_format(('Bob', 'Alice'), string_quotes='"'))
Esempio n. 13
0
 def test_format_single_str_quote(self):
     self.assertEqual('"John"', nice_format(('John', ), string_quotes='"'))
Esempio n. 14
0
 def test_format_many_str(self):
     self.assertEqual(
         'Bob, Alice, Charles, Donald and Eric',
         nice_format(('Bob', 'Alice', 'Charles', 'Donald', 'Eric')))