File: test_py2_import.py

package info (click to toggle)
sympy 1.14.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 36,784 kB
  • sloc: python: 460,598; xml: 359; makefile: 162; sh: 59; lisp: 4
file content (25 lines) | stat: -rwxr-xr-x 808 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env python
#
# Tests that a useful message is give in the ImportError when trying to import
# sympy from Python 2. This ensures that we don't get a Py2 SyntaxError from
# sympy/__init__.py

import sys
assert sys.version_info[:2] == (2, 7), "This test is for Python 2.7 only"

import os
thisdir = os.path.dirname(__file__)
parentdir = os.path.normpath(os.path.join(thisdir, '..'))

# Append the SymPy root directory to path
sys.path.append(parentdir)

try:
    import sympy # noqa: F401
except ImportError as exc:
    message = str(exc)
    # e.g. "Python version 3.5 or above is required for SymPy."
    assert message.startswith("Python version")
    assert message.endswith(" or above is required for SymPy.")
else:
    raise AssertionError("import sympy should give ImportError on Python 2.7")