Skip to content

Commit e5802a5

Browse files
authored
Add test that importing spatialmath does not load scipy
Add a test to ensure scipy is not loaded when importing spatialmath.
1 parent a105dbb commit e5802a5

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎tests/test_import.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import subprocess
2+
import sys
3+
import unittest
4+
5+
6+
class TestImport(unittest.TestCase):
7+
def test_import_does_not_load_scipy(self):
8+
# scipy is slow to import and only a few functions need it, so it is
9+
# imported by those functions and not when spatialmath is imported
10+
code = "import sys, spatialmath; sys.exit(any(m.split('.')[0] == 'scipy' for m in sys.modules))"
11+
result = subprocess.run([sys.executable, "-c", code])
12+
self.assertEqual(result.returncode, 0, "import spatialmath loaded scipy")
13+
14+
15+
if __name__ == "__main__": # pragma nocover
16+
unittest.main()

0 commit comments

Comments
 (0)