gnucash unstable: Fix python test failure on Travis.

John Ralls jralls at code.gnucash.org
Tue Nov 28 21:04:40 EST 2017


Updated	 via  https://github.com/Gnucash/gnucash/commit/41656c92 (commit)
	from  https://github.com/Gnucash/gnucash/commit/c6ae007b (commit)



commit 41656c920e54f9e4f7693086a410372257229b00
Author: John Ralls <jralls at ceridwen.us>
Date:   Tue Nov 28 17:57:00 2017 -0800

    Fix python test failure on Travis.
    
    It seems that there are two possible exceptions depending on OS.

diff --git a/bindings/python/tests/test_numeric.py b/bindings/python/tests/test_numeric.py
index 2c367eb..86217c6 100644
--- a/bindings/python/tests/test_numeric.py
+++ b/bindings/python/tests/test_numeric.py
@@ -28,11 +28,13 @@ class TestGncNumeric( TestCase ):
         self.assertEqual(num.num(), 3)
         self.assertEqual(num.denom(), 1)
 
-        #One might think this would be an overflow error, but SWIG type-checks
-        #it first and discovers that it's too big to be an int64_t.
-        with self.assertRaises(TypeError):
+        with self.assertRaises(Exception) as context:
             GncNumeric((2**64)+1)
 
+        #On Linux it raises an OverflowError while on MacOS it's a TypeError.
+        self.assertTrue(isinstance(context.exception, TypeError) or
+                        isinstance(context.exception, OverflowError))
+
     def test_from_float(self):
         num = GncNumeric(3.1, 20, GNC_HOW_DENOM_FIXED | GNC_HOW_RND_NEVER)
         self.assertEqual(str(num), "62/20")



Summary of changes:
 bindings/python/tests/test_numeric.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)



More information about the gnucash-changes mailing list