update docs/tests

This commit is contained in:
InspectorCaracal 2022-07-03 20:31:08 -06:00
parent aeaff1d663
commit f55959336b
2 changed files with 5 additions and 0 deletions

View file

@ -68,6 +68,8 @@ class TestListToString(TestCase):
[1,2,3] -> '1; 2; 3'
with endsep=='and':
[1,2,3] -> '1, 2 and 3'
with endsep=='':
[1,2,3] -> '1, 2 3'
with addquote and endsep="and"
[1,2,3] -> '"1", "2" and "3"'
"""
@ -76,6 +78,7 @@ class TestListToString(TestCase):
self.assertEqual("1, 2, and 3", utils.list_to_string([1, 2, 3]))
self.assertEqual("1, 2, 3", utils.list_to_string([1, 2, 3], endsep=","))
self.assertEqual("1, 2 and 3", utils.list_to_string([1, 2, 3], endsep="and"))
self.assertEqual("1, 2 3", utils.list_to_string([1, 2, 3], endsep=""))
self.assertEqual("1; 2; 3", utils.list_to_string([1, 2, 3], sep=";", endsep=";"))
self.assertEqual('"1", "2", "3"', utils.list_to_string([1, 2, 3], endsep=",", addquote=True))
self.assertEqual(

View file

@ -388,6 +388,8 @@ def iter_to_str(iterable, sep=",", endsep=", and", addquote=False):
```python
>>> list_to_string([1,2,3], endsep=',')
'1, 2, 3'
>>> list_to_string([1,2,3], endsep='')
'1, 2 3'
>>> list_to_string([1,2,3], ensdep='and')
'1, 2 and 3'
>>> list_to_string([1,2,3], sep=';', endsep=';')