From 24db3c123d784d476bc2b5d77e04cb7bb0956174 Mon Sep 17 00:00:00 2001 From: Roy Williams Date: Thu, 22 Sep 2016 09:22:12 -0700 Subject: [PATCH] Explicitly set to None to have consistent behavior in Python 2 and Python 3 --- _pytest/_code/code.py | 3 +-- _pytest/_code/source.py | 3 +-- _pytest/python.py | 6 ++---- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/_pytest/_code/code.py b/_pytest/_code/code.py index 21e1460fd..30e12940b 100644 --- a/_pytest/_code/code.py +++ b/_pytest/_code/code.py @@ -29,8 +29,7 @@ class Code(object): def __eq__(self, other): return self.raw == other.raw - def __hash__(self): - return hash(self.raw) + __hash__ = None def __ne__(self, other): return not self == other diff --git a/_pytest/_code/source.py b/_pytest/_code/source.py index ae9f0463f..2d55cd07f 100644 --- a/_pytest/_code/source.py +++ b/_pytest/_code/source.py @@ -52,8 +52,7 @@ class Source(object): return str(self) == other return False - def __hash__(self): - return hash(self.lines) + __hash__ = None def __getitem__(self, key): if isinstance(key, int): diff --git a/_pytest/python.py b/_pytest/python.py index ebfb8e1d1..ea194f85f 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -1356,8 +1356,7 @@ class approx(object): return False return all(a == x for a, x in zip(actual, self.expected)) - def __hash__(self): - return hash(self.expected) + __hash__ = None def __ne__(self, actual): return not (actual == self) @@ -1438,8 +1437,7 @@ class ApproxNonIterable(object): # Return true if the two numbers are within the tolerance. return abs(self.expected - actual) <= self.tolerance - def __hash__(self): - return hash((self.expected, self.tolerance)) + __hash__ = None def __ne__(self, actual): return not (actual == self)