TestDictableNamedtuple¶
-
class
tests.test_collections.
TestDictableNamedtuple
(methodName='runTest')[source]¶ Test the function
dictable_namedtuple()
and compare it againstcollections.namedtuple()
to ensure that dictable_namedtuple’s should be backwards compatible with code that takes namedtuple’s.Also tests new functionality that only exists in dictable_namedtuple’s, and compares it against standard namedtuples, including:
Test getting by item/key, i.e.
john['first_name']
, and confirm normal namedtuples raise exceptionsTest setting new item/key’s and attributes
item['color'] = 'Brown'
, and confirm normal namedtuples raise exceptionsTest casting dictable namedtuple’s to dict’s
dict(item)
, and confirm normal namedtuples raise exceptions
-
__init__
(methodName='runTest') Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
Methods¶
Methods
|
At the start of each test, reset |
Test |
|
Test convert_dictable_namedtuple converts example namedtuple instance into a dictable_namedtuple instance |
|
Test casting dictable_namedtuple using |
|
Confirm getting attributes is equivalent on dictable namedtuple to standard namedtuple |
|
Test we can access by integer index on dictable + normal namedtuple |
|
Test we can access named items on on dictable namedtuple while standard namedtuple raises exceptions |
|
Confirm sameness of class/instance metadata such as class name/qualname, module name, and stringification between |
|
Test that we can create the new attribute |
|
Test that we can create the new item/key |
|
Test subclass_dictable_namedtuple converts |