From 52a3a71179b1c1bc01ce6cf75c8cc393c64c510f Mon Sep 17 00:00:00 2001 From: Dan Tao Date: Wed, 6 Dec 2017 09:10:43 -0600 Subject: [PATCH] add test for schema equality (see #315) --- voluptuous/tests/tests.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/voluptuous/tests/tests.py b/voluptuous/tests/tests.py index cc0ed61..db328a6 100644 --- a/voluptuous/tests/tests.py +++ b/voluptuous/tests/tests.py @@ -410,6 +410,27 @@ def test_subschema_extension(): assert_equal(extended.schema, {'a': {'b': str, 'c': float, 'e': int}, 'd': str}) +def test_equality(): + assert_equal(Schema('foo'), Schema('foo')) + + assert_equal(Schema(['foo', 'bar', 'baz']), + Schema(['foo', 'bar', 'baz'])) + + # Ensure two Schemas w/ two equivalent dicts initialized in a different + # order are considered equal. + dict_a = {} + dict_a['foo'] = 1 + dict_a['bar'] = 2 + dict_a['baz'] = 3 + + dict_b = {} + dict_b['baz'] = 3 + dict_b['bar'] = 2 + dict_b['foo'] = 1 + + assert_equal(Schema(dict_a), Schema(dict_b)) + + def test_repr(): """Verify that __repr__ returns valid Python expressions""" match = Match('a pattern', msg='message')