Exemplo n.º 1
0
 def test_notString(self):
     """
     If something in things is not a string, it is converted into one.
     """
     sample = [1, 2, 'three']
     expected = '1, 2, and three'
     result = util._listToPhrase(sample, 'and')
     self.assertEqual(expected, result)
Exemplo n.º 2
0
 def test_threeWords(self):
     """
     With more than two words, the first two are separated by the delimiter.
     """
     sample = ['One', 'Two', 'Three']
     expected = 'One, Two, and Three'
     result = util._listToPhrase(sample, 'and')
     self.assertEqual(expected, result)
Exemplo n.º 3
0
 def test_fourWords(self):
     """
     If a delimiter is specified, it is used instead of the default comma.
     """
     sample = ['One', 'Two', 'Three', 'Four']
     expected = 'One; Two; Three; or Four'
     result = util._listToPhrase(sample, 'or', delimiter='; ')
     self.assertEqual(expected, result)
Exemplo n.º 4
0
 def test_oneWord(self):
     """
     With a single item, the item is returned.
     """
     sample = ['One']
     expected = 'One'
     result = util._listToPhrase(sample, 'and')
     self.assertEqual(expected, result)
Exemplo n.º 5
0
 def test_twoWords(self):
     """
     Two words are separated by the final delimiter.
     """
     sample = ['One', 'Two']
     expected = 'One and Two'
     result = util._listToPhrase(sample, 'and')
     self.assertEqual(expected, result)
Exemplo n.º 6
0
 def test_fourWords(self):
     """
     If a delimiter is specified, it is used instead of the default comma.
     """
     sample = ["One", "Two", "Three", "Four"]
     expected = "One; Two; Three; or Four"
     result = util._listToPhrase(sample, "or", delimiter="; ")
     self.assertEqual(expected, result)
Exemplo n.º 7
0
 def test_empty(self):
     """
     If things is empty, an empty string is returned.
     """
     sample = []
     expected = ''
     result = util._listToPhrase(sample, 'and')
     self.assertEqual(expected, result)
Exemplo n.º 8
0
 def test_twoWords(self):
     """
     Two words are separated by the final delimiter.
     """
     sample = ["One", "Two"]
     expected = "One and Two"
     result = util._listToPhrase(sample, "and")
     self.assertEqual(expected, result)
Exemplo n.º 9
0
 def test_threeWords(self):
     """
     With more than two words, the first two are separated by the delimiter.
     """
     sample = ["One", "Two", "Three"]
     expected = "One, Two, and Three"
     result = util._listToPhrase(sample, "and")
     self.assertEqual(expected, result)
Exemplo n.º 10
0
 def test_notString(self):
     """
     If something in things is not a string, it is converted into one.
     """
     sample = [1, 2, 'three']
     expected = '1, 2, and three'
     result = util._listToPhrase(sample, 'and')
     self.assertEqual(expected, result)
Exemplo n.º 11
0
 def test_oneWord(self):
     """
     With a single item, the item is returned.
     """
     sample = ["One"]
     expected = "One"
     result = util._listToPhrase(sample, "and")
     self.assertEqual(expected, result)
Exemplo n.º 12
0
 def test_fourWords(self):
     """
     If a delimiter is specified, it is used instead of the default comma.
     """
     sample = ['One', 'Two', 'Three', 'Four']
     expected = 'One; Two; Three; or Four'
     result = util._listToPhrase(sample, 'or', delimiter='; ')
     self.assertEqual(expected, result)
Exemplo n.º 13
0
 def test_threeWords(self):
     """
     With more than two words, the first two are separated by the delimiter.
     """
     sample = ['One', 'Two', 'Three']
     expected = 'One, Two, and Three'
     result = util._listToPhrase(sample, 'and')
     self.assertEqual(expected, result)
Exemplo n.º 14
0
 def test_twoWords(self):
     """
     Two words are separated by the final delimiter.
     """
     sample = ['One', 'Two']
     expected = 'One and Two'
     result = util._listToPhrase(sample, 'and')
     self.assertEqual(expected, result)
Exemplo n.º 15
0
 def test_oneWord(self):
     """
     With a single item, the item is returned.
     """
     sample = ['One']
     expected = 'One'
     result = util._listToPhrase(sample, 'and')
     self.assertEqual(expected, result)
Exemplo n.º 16
0
 def test_empty(self):
     """
     If things is empty, an empty string is returned.
     """
     sample = []
     expected = ''
     result = util._listToPhrase(sample, 'and')
     self.assertEqual(expected, result)