def test_settings_with_user_none(self): user_settings = None default_settings = dict(a=False, linewidth=3, marker=dict(markersize=5, color='g')) settings = check_settings(default_settings=default_settings, user_settings=user_settings) self.assertEqual(settings, default_settings, msg=str( 'Expect dictionaries to match: {} neq {}'.format( settings, default_settings)))
def test_settings_with_subdict(self): user_settings = dict(a=True, fontsize=12) default_settings = dict(a=False, linewidth=3, marker=dict(markersize=5, color='g')) settings = check_settings(default_settings=default_settings, user_settings=user_settings) self.assertEqual(settings['a'], user_settings['a'], msg='Expect user setting to overwrite') self.assertEqual(settings['marker'], default_settings['marker'], msg='Expect default to persist')
def test_settings_with_subdict_user_has_new_setting(self): user_settings = dict(a=True, fontsize=12, marker=dict(color='b'), linestyle='--') default_settings = dict(a=False, linewidth=3, marker=dict(markersize=5, color='g')) settings = check_settings(default_settings=default_settings, user_settings=user_settings) self.assertEqual(settings['a'], user_settings['a'], msg='Expect user setting to overwrite') self.assertEqual(settings['marker']['color'], user_settings['marker']['color'], msg='Expect user to overwrite') self.assertEqual(settings['marker']['markersize'], default_settings['marker']['markersize'], msg='Expect default to persist') self.assertEqual(settings['linestyle'], user_settings['linestyle'], msg='Expect user setting to be added')