Skip to content

Commit

Permalink
add negative equality tests
Browse files Browse the repository at this point in the history
This fills in missing test coverage to ensure the __eq__ method does not
return True in some potentially unexpected cases (these tests would fail
before be867c5).
  • Loading branch information
dtao committed Dec 6, 2017
1 parent be867c5 commit 2c5c378
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion voluptuous/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import sys

from nose.tools import assert_equal, assert_raises, assert_true
from nose.tools import assert_equal, assert_false, assert_raises, assert_true

from voluptuous import (
Schema, Required, Exclusive, Optional, Extra, Invalid, In, Remove, Literal,
Expand Down Expand Up @@ -431,6 +431,17 @@ def test_equality():
assert_equal(Schema(dict_a), Schema(dict_b))


def test_equality_negative():
"""Verify that Schema objects are not equal to string representations"""
assert_false(Schema('foo') == 'foo')

assert_false(Schema(['foo', 'bar']) == "['foo', 'bar']")
assert_false(Schema(['foo', 'bar']) == Schema("['foo', 'bar']"))

assert_false(Schema({'foo': 1, 'bar': 2}) == "{'foo': 1, 'bar': 2}")
assert_false(Schema({'foo': 1, 'bar': 2}) == Schema("{'foo': 1, 'bar': 2}"))


def test_repr():
"""Verify that __repr__ returns valid Python expressions"""
match = Match('a pattern', msg='message')
Expand Down

0 comments on commit 2c5c378

Please sign in to comment.