diff --git a/py/code/code.py b/py/code/code.py index a01984383..6e1adc403 100644 --- a/py/code/code.py +++ b/py/code/code.py @@ -15,7 +15,7 @@ class Code(object): def __eq__(self, other): return self.raw == other.raw - def __ne__(self): + def __ne__(self, other): return not self == other def new(self, rec=False, **kwargs): diff --git a/py/code/testing/test_code.py b/py/code/testing/test_code.py index c2b0ff978..ae2fbb93a 100644 --- a/py/code/testing/test_code.py +++ b/py/code/testing/test_code.py @@ -8,6 +8,12 @@ def test_newcode(): newco = code.new() assert co == newco +def test_ne(): + code1 = py.code.Code(compile('foo = "bar"', '', 'exec')) + assert code1 == code1 + code2 = py.code.Code(compile('foo = "baz"', '', 'exec')) + assert code2 != code1 + def test_newcode_unknown_args(): code = py.code.Code(compile("", '', 'exec')) py.test.raises(TypeError, 'code.new(filename="hello")')