Skip to content

Commit

Permalink
Begin tests for trigger.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Oct 26, 2017
1 parent d3d93d4 commit a9409cd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/zope/server/tests/test_trigger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
"""
Tests for trigger.py
"""

import unittest

from zope.server import trigger

class TestFunctions(unittest.TestCase):

def test_positive_id(self):

trigger.id = lambda o: -42
try:
# This is possibly only correct on 64-bit platforms
self.assertEqual(18446744073709551574L,
trigger.positive_id(None))
finally:
del trigger.id
2 changes: 1 addition & 1 deletion src/zope/server/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
_ADDRESS_MASK = 256 ** struct.calcsize('P')
def positive_id(obj):
"""Return id(obj) as a non-negative integer."""

# Note that the output depends on the size of void* on the platform.
result = id(obj)
if result < 0:
result += _ADDRESS_MASK
Expand Down

0 comments on commit a9409cd

Please sign in to comment.