kyu_6.format_string_of_names package

Submodules

kyu_6.format_string_of_names.solution module

Solution for -> Format a string of names like ‘Bart, Lisa & Maggie’.

Created by Egor Kostan. GitHub: https://github.com/ikostan

kyu_6.format_string_of_names.solution.namelist(names: list) str[source]

Format a string of names like ‘Bart, Lisa & Maggie’.

Parameters:

names – an array containing hashes of names

Returns:

a string formatted as a list of names separated by commas except for the last two names, which should be separated by an ampersand.

kyu_6.format_string_of_names.test_namelist module

Test for -> Format a string of names like ‘Bart, Lisa & Maggie’.

Created by Egor Kostan. GitHub: https://github.com/ikostan

class kyu_6.format_string_of_names.test_namelist.NamelistTestCase(methodName='runTest')[source]

Bases: TestCase

Testing namelist function.

_classSetupFailed = False
_class_cleanups = []
test_namelist = None
test_namelist_0(**kw)

Test namelist [with names=[{‘name’: ‘Bart’}, {‘name’: ‘Lis…e’: ‘Homer’}, {‘name’: ‘Marge’}], expected=’Bart, Lisa, Maggie, Homer & Marge’, message=’Must work with many names’].

Given: an array containing hashes of names

Return: a string formatted as a list of names separated by commas except for the last two names, which should be separated by an ampersand.

Returns:

test_namelist_1(**kw)

Test namelist [with names=[{‘name’: ‘Bart’}, {‘name’: ‘Lisa’}, {‘name’: ‘Maggie’}], expected=’Bart, Lisa & Maggie’, message=’Must work with many names’].

Given: an array containing hashes of names

Return: a string formatted as a list of names separated by commas except for the last two names, which should be separated by an ampersand.

Returns:

test_namelist_2(**kw)

Test namelist [with names=[{‘name’: ‘Bart’}, {‘name’: ‘Lisa’}], expected=’Bart & Lisa’, message=’Must work with two names’].

Given: an array containing hashes of names

Return: a string formatted as a list of names separated by commas except for the last two names, which should be separated by an ampersand.

Returns:

test_namelist_3(**kw)

Test namelist [with names=[{‘name’: ‘Bart’}], expected=’Bart’, message=’Wrong output for a single name’].

Given: an array containing hashes of names

Return: a string formatted as a list of names separated by commas except for the last two names, which should be separated by an ampersand.

Returns:

test_namelist_4(**kw)

Test namelist [with names=[], expected=’’, message=’Must work with no names’].

Given: an array containing hashes of names

Return: a string formatted as a list of names separated by commas except for the last two names, which should be separated by an ampersand.

Returns:

Module contents

Format a string of names like ‘Bart, Lisa & Maggie’.