Example #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)
Example #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)
Example #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)
Example #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)
Example #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)
Example #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)
Example #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)
Example #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)
Example #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)
Example #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)
Example #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)
Example #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)
Example #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)
Example #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)
Example #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)
Example #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)