summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-02-15 13:55:00 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2011-02-16 20:08:34 -0300
commit364525b5d30830e6fe7a2936e155235c19fc1465 (patch)
tree329e6f230094ae1df17537c34114628a89eba21b /tests
parentdc2c701cd58efcd6559e3b1e510aa17b8942dd5f (diff)
downloadshiboken-364525b5d30830e6fe7a2936e155235c19fc1465.tar.gz
shiboken-364525b5d30830e6fe7a2936e155235c19fc1465.tar.xz
shiboken-364525b5d30830e6fe7a2936e155235c19fc1465.zip
Added a test to numpy scalar type being accepted as Python scalar.
Diffstat (limited to 'tests')
-rw-r--r--tests/samplebinding/numpy_test.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/samplebinding/numpy_test.py b/tests/samplebinding/numpy_test.py
new file mode 100644
index 00000000..e422a998
--- /dev/null
+++ b/tests/samplebinding/numpy_test.py
@@ -0,0 +1,30 @@
+import sys
+
+try:
+ from distutils import sysconfig
+ if bool(sysconfig.get_config_var('Py_DEBUG')):
+ sys.exit(0)
+ import numpy
+except:
+ sys.exit(0)
+
+import unittest
+from sample import PointF
+
+class TestNumpyTypes(unittest.TestCase):
+
+ def testNumpyConverted(self):
+ x, y = (0.1, 0.2)
+ p = PointF(float(numpy.float32(x)), float(numpy.float32(y)))
+ self.assertAlmostEqual(p.x(), x)
+ self.assertAlmostEqual(p.y(), y)
+
+ def testNumpyAsIs(self):
+ x, y = (0.1, 0.2)
+ p = PointF(numpy.float32(x), numpy.float32(y))
+ self.assertAlmostEqual(p.x(), x)
+ self.assertAlmostEqual(p.y(), y)
+
+if __name__ == "__main__":
+ unittest.main()
+