def test_del_item(settings: Settings) -> None: settings._store = OrderedDict([(Reference('param1'), 'test'), (Reference('param2'), 0)]) del settings['param1'] assert len(settings._store) == 1 assert Reference('param1') not in settings._store with pytest.raises(KeyError): settings['param1'] # pylint: disable=pointless-statement assert settings._store[Reference('param2')] == 0
def test_as_ordered_dict(settings: Settings) -> None: settings._store = OrderedDict([(Reference('test1'), 12), (Reference('test2'), '12'), (Reference('test3'), 'testing'), (Reference('test4'), [12.3, 45.6])]) settings_dict = settings.as_ordered_dict() assert settings_dict['test1'] == 12 assert settings_dict['test2'] == '12' assert settings_dict['test3'] == 'testing' assert settings_dict['test4'] == [12.3, 45.6] for i, (key, _) in enumerate(settings_dict.items()): assert key == 'test{}'.format(i + 1)
def test_iter(settings: Settings) -> None: assert len(settings) == 0 for setting, value in settings.items(): assert False # pragma: no cover settings._store = OrderedDict([(Reference('test1'), 13), (Reference('test2'), 'testing'), (Reference('test3'), [3.4, 5.6])]) assert len(settings) == 3 for setting in settings: assert setting in settings for setting, value in settings.items(): assert (setting == 'test1' and value == 13 or setting == 'test2' and value == 'testing' or setting == 'test3' and value == [3.4, 5.6])