Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Hopefully fixed py 2.6 issues
  • Loading branch information
sigbjorn committed Jul 4, 2016
commit e58d5b25cf35b9cc28b00425bfd6b24c39eab0d6
5 changes: 4 additions & 1 deletion src/tests/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,11 @@ def testConstructorRaiseExceptionIfNoMatch(self):


if constructor_throw_on_arg_match_is_fixed:
with self.assertRaises(TypeError):
try:
o = ToDoubleConstructorTest('a','not a number','c') # this should raise exception, because there are no match!
except TypeError:
return
self.fail("exception should be raised for non-matching constructor atempt")
else:
print("\n\n*** Warning: failing arg match on constructors are currently silently accepted if there is a null constructor\n")

Expand Down
20 changes: 11 additions & 9 deletions src/tests/test_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,13 @@ def testSimpleTypePromotionIntToDouble(self):
sum_of_a_plus_b = object.TestSimpleIntToDoubleTypePromotion(2.0,2.0)
self.assertAlmostEqual(sum_of_a_plus_b,2.0+2.0)

with self.assertRaises(TypeError):
#with self.assertRaises(TypeError), wont work on py 2.6, so ..
try:
should_fail = object.TestSimpleIntToDoubleTypePromotion(2,'x2.0')
#with self.assertRaises(TypeError):
# should_fail = object.TestSimpleIntToDoubleTypePromotion(2,True)
except TypeError:
return
self.fail("A string (not convertible to number), should throw type error")
# TODO: consider this for consistence: bool True-> 1.0, False -> 0.0

def testSimpleTypePromotionIntToFloat(self):
object = MethodTest()
Expand All @@ -235,13 +238,12 @@ def testSimpleTypePromotionIntToFloat(self):
self.assertAlmostEqual(sum_of_a_plus_b,2+2)
sum_of_a_plus_b = object.TestSimpleIntToFloatTypePromotion(2.0,2.0)
self.assertAlmostEqual(sum_of_a_plus_b,2.0+2.0)

with self.assertRaises(TypeError):
try:
should_fail = object.TestSimpleIntToFloatTypePromotion(2,'x2.0')
# bool True-> 1.0, False -> 0.0
#with self.assertRaises(TypeError):
# should_fail = object.TestSimpleIntToFloatTypePromotion(2,True)
# print("And the unexpected result is...",should_fail)
except TypeError:
return
self.fail("A string (not convertible to number), should throw type error")
# TODO: consider this for consistence: bool True-> 1.0, False -> 0.0

def testMethodCallStructConversion(self):
"""Test struct conversion in method call."""
Expand Down