Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
persistent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
persistent
Commits
7f673b53
Commit
7f673b53
authored
Apr 10, 2015
by
Tres Seaver
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #23 from NextThought/issue21
Fix tests for TimeStamp hashcode under 32-bit Pythons.
parents
cad848ac
cd847ce2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
7 deletions
+29
-7
persistent/tests/test_timestamp.py
persistent/tests/test_timestamp.py
+29
-7
No files found.
persistent/tests/test_timestamp.py
View file @
7f673b53
...
@@ -272,7 +272,9 @@ class PyAndCComparisonTests(unittest.TestCase):
...
@@ -272,7 +272,9 @@ class PyAndCComparisonTests(unittest.TestCase):
self
.
assertEqual
(
hash
(
py
),
bit_32_hash
)
self
.
assertEqual
(
hash
(
py
),
bit_32_hash
)
persistent
.
timestamp
.
c_long
=
ctypes
.
c_int64
persistent
.
timestamp
.
c_long
=
ctypes
.
c_int64
self
.
assertEqual
(
hash
(
py
),
bit_64_hash
)
# call __hash__ directly to avoid interpreter truncation
# in hash() on 32-bit platforms
self
.
assertEqual
(
py
.
__hash__
(),
bit_64_hash
)
finally
:
finally
:
persistent
.
timestamp
.
c_long
=
orig_c_long
persistent
.
timestamp
.
c_long
=
orig_c_long
...
@@ -286,6 +288,10 @@ class PyAndCComparisonTests(unittest.TestCase):
...
@@ -286,6 +288,10 @@ class PyAndCComparisonTests(unittest.TestCase):
def
test_hash_equal_constants
(
self
):
def
test_hash_equal_constants
(
self
):
# The simple constants make it easier to diagnose
# The simple constants make it easier to diagnose
# a difference in algorithms
# a difference in algorithms
import
persistent.timestamp
import
ctypes
is_32_bit
=
persistent
.
timestamp
.
c_long
==
ctypes
.
c_int32
c
,
py
=
self
.
_make_C_and_Py
(
b'
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
'
)
c
,
py
=
self
.
_make_C_and_Py
(
b'
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
'
)
self
.
assertEqual
(
hash
(
c
),
8
)
self
.
assertEqual
(
hash
(
c
),
8
)
self
.
assertEqual
(
hash
(
c
),
hash
(
py
))
self
.
assertEqual
(
hash
(
c
),
hash
(
py
))
...
@@ -298,24 +304,40 @@ class PyAndCComparisonTests(unittest.TestCase):
...
@@ -298,24 +304,40 @@ class PyAndCComparisonTests(unittest.TestCase):
self
.
assertEqual
(
hash
(
c
),
1000011
)
self
.
assertEqual
(
hash
(
c
),
1000011
)
self
.
assertEqual
(
hash
(
c
),
hash
(
py
))
self
.
assertEqual
(
hash
(
c
),
hash
(
py
))
# overflow kicks in here on 32-bit platforms
c
,
py
=
self
.
_make_C_and_Py
(
b'
\
x00
\
x00
\
x00
\
x00
\
x00
\
x01
\
x00
\
x00
'
)
c
,
py
=
self
.
_make_C_and_Py
(
b'
\
x00
\
x00
\
x00
\
x00
\
x00
\
x01
\
x00
\
x00
'
)
if
is_32_bit
:
self
.
assertEqual
(
hash
(
c
),
-
721379967
)
else
:
self
.
assertEqual
(
hash
(
c
),
1000006000001
)
self
.
assertEqual
(
hash
(
c
),
1000006000001
)
self
.
assertEqual
(
hash
(
c
),
hash
(
py
))
self
.
assertEqual
(
hash
(
c
),
hash
(
py
))
c
,
py
=
self
.
_make_C_and_Py
(
b'
\
x00
\
x00
\
x00
\
x00
\
x01
\
x00
\
x00
\
x00
'
)
c
,
py
=
self
.
_make_C_and_Py
(
b'
\
x00
\
x00
\
x00
\
x00
\
x01
\
x00
\
x00
\
x00
'
)
if
is_32_bit
:
self
.
assertEqual
(
hash
(
c
),
583896275
)
else
:
self
.
assertEqual
(
hash
(
c
),
1000009000027000019
)
self
.
assertEqual
(
hash
(
c
),
1000009000027000019
)
self
.
assertEqual
(
hash
(
c
),
hash
(
py
))
self
.
assertEqual
(
hash
(
c
),
hash
(
py
))
# Overflow kicks in at this point
# Overflow kicks in at this point
on 64-bit platforms
c
,
py
=
self
.
_make_C_and_Py
(
b'
\
x00
\
x00
\
x00
\
x01
\
x00
\
x00
\
x00
\
x00
'
)
c
,
py
=
self
.
_make_C_and_Py
(
b'
\
x00
\
x00
\
x00
\
x01
\
x00
\
x00
\
x00
\
x00
'
)
if
is_32_bit
:
self
.
assertEqual
(
hash
(
c
),
1525764953
)
else
:
self
.
assertEqual
(
hash
(
c
),
-
4442925868394654887
)
self
.
assertEqual
(
hash
(
c
),
-
4442925868394654887
)
self
.
assertEqual
(
hash
(
c
),
hash
(
py
))
self
.
assertEqual
(
hash
(
c
),
hash
(
py
))
c
,
py
=
self
.
_make_C_and_Py
(
b'
\
x00
\
x00
\
x01
\
x00
\
x00
\
x00
\
x00
\
x00
'
)
c
,
py
=
self
.
_make_C_and_Py
(
b'
\
x00
\
x00
\
x01
\
x00
\
x00
\
x00
\
x00
\
x00
'
)
if
is_32_bit
:
self
.
assertEqual
(
hash
(
c
),
-
429739973
)
else
:
self
.
assertEqual
(
hash
(
c
),
-
3993531167153147845
)
self
.
assertEqual
(
hash
(
c
),
-
3993531167153147845
)
self
.
assertEqual
(
hash
(
c
),
hash
(
py
))
self
.
assertEqual
(
hash
(
c
),
hash
(
py
))
c
,
py
=
self
.
_make_C_and_Py
(
b'
\
x01
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
'
)
c
,
py
=
self
.
_make_C_and_Py
(
b'
\
x01
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
'
)
if
is_32_bit
:
self
.
assertEqual
(
hash
(
c
),
263152323
)
else
:
self
.
assertEqual
(
hash
(
c
),
-
3099646879006235965
)
self
.
assertEqual
(
hash
(
c
),
-
3099646879006235965
)
self
.
assertEqual
(
hash
(
c
),
hash
(
py
))
self
.
assertEqual
(
hash
(
c
),
hash
(
py
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment