Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix object identity tests for more architectures, as well as PyPy

  • Loading branch information...
commit d8defbf3ecbe8a4439c015b6497eaa82dc5d9d4d 1 parent f12a903
Chris Rose authored
Showing with 6 additions and 4 deletions.
  1. +6 −4 hamcrest_unit_test/core/issame_test.py
View
10 hamcrest_unit_test/core/issame_test.py
@@ -14,6 +14,8 @@
__copyright__ = "Copyright 2011 hamcrest.org"
__license__ = "BSD, see License.txt"
+ADDRESS_FORMAT = r"-?0x[0-9a-fA-F]+L?"
+
class IsSameTest(MatcherTest):
@@ -26,7 +28,7 @@ def testEvaluatesToTrueIfArgumentIsReferenceToASpecifiedObject(self):
def testDescriptionIncludesMemoryAddress(self):
description = StringDescription()
- expected = re.compile("same instance as 0x[0-9a-fA-F]+ 'abc'")
+ expected = re.compile("same instance as " + ADDRESS_FORMAT + " 'abc'")
description.append_description_of(same_instance('abc'));
self.assertTrue(expected.match(str(description)))
@@ -38,7 +40,7 @@ def testSuccessfulMatchDoesNotGenerateMismatchDescription(self):
def testMismatchDescriptionShowsActualArgumentAddress(self):
matcher = same_instance('foo')
description = StringDescription()
- expected = re.compile("was 0x[0-9a-fA-F]+ 'hi'")
+ expected = re.compile("was " + ADDRESS_FORMAT + " 'hi'")
result = matcher.matches('hi', description)
self.assertFalse(result, 'Precondition: Matcher should not match item')
@@ -50,10 +52,10 @@ def testMismatchDescriptionWithNilShouldNotIncludeAddress(self):
def testDescribeMismatch(self):
matcher = same_instance('foo')
description = StringDescription()
- expected = re.compile("was 0x[0-9a-fA-F]+ 'hi'")
+ expected = re.compile("was " + ADDRESS_FORMAT + " 'hi'")
matcher.describe_mismatch('hi', description)
- expected = re.compile("was 0x[0-9a-fA-F]+ 'hi'")
+ expected = re.compile("was " + ADDRESS_FORMAT + " 'hi'")
self.assertTrue(expected.match(str(description)),
"Expected %s to match %s" % (str(matcher), str(description)))
Please sign in to comment.
Something went wrong with that request. Please try again.