Skip to content

Commit

Permalink
fix p3 problems of the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wlav committed Oct 12, 2017
1 parent 47008a3 commit 03cf6d8
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 30 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

setup(
name='cppyy',
version='0.3.2',
version='0.3.4',
description='Cling-based Python-C++ bindings',
long_description=long_description,

Expand Down
2 changes: 2 additions & 0 deletions test/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ def setup_make(targetname):

if sys.hexversion >= 0x3000000:
pylong = int
maxvalue = sys.maxsize
else:
pylong = long
maxvalue = sys.maxint
30 changes: 15 additions & 15 deletions test/test_advancedcpp.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import py, os, sys
from pytest import raises
from .support import setup_make
from .support import setup_make, pylong

currpath = py.path.local(__file__).dirpath()
test_dct = str(currpath.join("advancedcppDict.so"))
Expand Down Expand Up @@ -46,15 +46,15 @@ def test_defaulter(n, t):
assert d.m_b == t(4)
assert d.m_c == t(5)
d.__destruct__()
test_defaulter('short', int)
test_defaulter('short', int)
test_defaulter('ushort', int)
test_defaulter('int', int)
test_defaulter('uint', int)
test_defaulter('long', long)
test_defaulter('ulong', long)
test_defaulter('llong', long)
test_defaulter('ullong', long)
test_defaulter('float', float)
test_defaulter('int', int)
test_defaulter('uint', int)
test_defaulter('long', pylong)
test_defaulter('ulong', pylong)
test_defaulter('llong', pylong)
test_defaulter('ullong', pylong)
test_defaulter('float', float)
test_defaulter('double', float)

def test02_simple_inheritance(self):
Expand Down Expand Up @@ -469,7 +469,7 @@ def test11_multi_methods(self):
assert cppyy.gbl.multi1 is multi.__bases__[0]
assert cppyy.gbl.multi2 is multi.__bases__[1]

dict_keys = multi.__dict__.keys()
dict_keys = list(multi.__dict__.keys())
assert dict_keys.count('get_my_own_int') == 1
assert dict_keys.count('get_multi1_int') == 0
assert dict_keys.count('get_multi2_int') == 0
Expand Down Expand Up @@ -599,12 +599,12 @@ def test18_math_converters(self):
a.m_i = 1234
a.m_d = 4321.

assert int(a) == 1234
assert int(a) == a.m_i
assert long(a) == a.m_i
assert int(a) == 1234
assert int(a) == a.m_i
assert pylong(a) == a.m_i

assert float(a) == 4321.
assert float(a) == a.m_d
assert float(a) == 4321.
assert float(a) == a.m_d

def test19_comparator(self):
"""Check that the global operator!=/== is picked up"""
Expand Down
8 changes: 4 additions & 4 deletions test/test_datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def test01_instance_data_read_access(self):
raises(IndexError, c.m_double_array.__getitem__, self.N)

# can not access an instance member on the class
raises(ReferenceError, getattr, CppyyTestData, 'm_bool')
raises(ReferenceError, getattr, CppyyTestData, 'm_int')
raises(AttributeError, getattr, CppyyTestData, 'm_bool')
raises(AttributeError, getattr, CppyyTestData, 'm_int')

assert not hasattr(CppyyTestData, 'm_bool')
assert not hasattr(CppyyTestData, 'm_int')
Expand Down Expand Up @@ -585,11 +585,11 @@ def test14_object_arguments(self):
assert p.m_double == 3.14

def test15_nullptr_passing(self):
"""Integer 0 ('NULL') and None allowed to pass through instance*"""
"""Integer 0 ('NULL') and nullptr allowed to pass through instance*"""

import cppyy

for o in (0, None):
for o in (0, cppyy.nullptr):
c = cppyy.gbl.CppyyTestData()
assert c.m_pod.m_int == 888
assert c.m_pod.m_double == 3.14
Expand Down
16 changes: 8 additions & 8 deletions test/test_operators.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import py, os, sys
from pytest import raises
from .support import setup_make
from .support import setup_make, pylong, maxvalue

currpath = py.path.local(__file__).dirpath()
test_dct = str(currpath.join("operatorsDict.so"))
Expand Down Expand Up @@ -102,8 +102,8 @@ def test05_exact_types(self):
assert int(o) == -13

o = gbl.operator_long(); o.m_long = 42
assert o.m_long == 42
assert long(o) == 42
assert o.m_long == 42
assert pylong(o) == 42

o = gbl.operator_double(); o.m_double = 3.1415
assert o.m_double == 3.1415
Expand All @@ -120,13 +120,13 @@ def test06_approximate_types(self):
assert int(o) == 256

o = gbl.operator_unsigned_int(); o.m_uint = 2147483647 + 32
assert o.m_uint == 2147483647 + 32
assert long(o) == 2147483647 + 32
assert o.m_uint == 2147483647 + 32
assert pylong(o) == 2147483647 + 32

o = gbl.operator_unsigned_long();
o.m_ulong = sys.maxint + 128
assert o.m_ulong == sys.maxint + 128
assert long(o) == sys.maxint + 128
o.m_ulong = maxvalue + 128
assert o.m_ulong == maxvalue + 128
assert pylong(o) == maxvalue + 128

o = gbl.operator_float(); o.m_float = 3.14
assert round(o.m_float - 3.14, 5) == 0.
Expand Down
8 changes: 6 additions & 2 deletions test/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class TestTEMPLATES:
def setup_class(cls):
cls.test_dct = test_dct
import cppyy
cls.advanced = cppyy.load_reflection_info(cls.test_dct)
cls.templates = cppyy.load_reflection_info(cls.test_dct)

def test01_template_member_functions(self):
"""Template member functions lookup and calls"""
Expand All @@ -27,7 +27,11 @@ def test01_template_member_functions(self):
assert m.get_size[int]() == m.get_int_size()

# specialized
assert m.get_size[long]() == m.get_long_size()
if sys.hexversion >= 0x3000000:
targ = 'long'
else:
targ = long
assert m.get_size[targ]() == m.get_long_size()

# auto-instantiation
assert m.get_size[float]() == m.get_float_size()
Expand Down

0 comments on commit 03cf6d8

Please sign in to comment.