test_importtools.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. from sympy.external import import_module
  2. from sympy.testing.pytest import warns
  3. # fixes issue that arose in addressing issue 6533
  4. def test_no_stdlib_collections():
  5. '''
  6. make sure we get the right collections when it is not part of a
  7. larger list
  8. '''
  9. import collections
  10. matplotlib = import_module('matplotlib',
  11. import_kwargs={'fromlist': ['cm', 'collections']},
  12. min_module_version='1.1.0', catch=(RuntimeError,))
  13. if matplotlib:
  14. assert collections != matplotlib.collections
  15. def test_no_stdlib_collections2():
  16. '''
  17. make sure we get the right collections when it is not part of a
  18. larger list
  19. '''
  20. import collections
  21. matplotlib = import_module('matplotlib',
  22. import_kwargs={'fromlist': ['collections']},
  23. min_module_version='1.1.0', catch=(RuntimeError,))
  24. if matplotlib:
  25. assert collections != matplotlib.collections
  26. def test_no_stdlib_collections3():
  27. '''make sure we get the right collections with no catch'''
  28. import collections
  29. matplotlib = import_module('matplotlib',
  30. import_kwargs={'fromlist': ['cm', 'collections']},
  31. min_module_version='1.1.0')
  32. if matplotlib:
  33. assert collections != matplotlib.collections
  34. def test_min_module_version_python3_basestring_error():
  35. with warns(UserWarning):
  36. import_module('mpmath', min_module_version='1000.0.1')