-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Expand file tree
/
Copy pathtest_basic.py
More file actions
46 lines (37 loc) · 1.03 KB
/
test_basic.py
File metadata and controls
46 lines (37 loc) · 1.03 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import builtins
import os
import subprocess
import sys
import textwrap
def test_simple():
assert 1 + 1 == 2
def test_override_builtins():
import pylab
ok_to_override = {
'__name__',
'__doc__',
'__package__',
'__loader__',
'__spec__',
'any',
'all',
'sum',
'divmod'
}
overridden = {key for key in {*dir(pylab)} & {*dir(builtins)}
if getattr(pylab, key) != getattr(builtins, key)}
assert overridden <= ok_to_override
def test_lazy_imports():
source = textwrap.dedent("""
import sys
import matplotlib.figure
import matplotlib.backend_bases
import matplotlib.pyplot
assert 'matplotlib._tri' not in sys.modules
assert 'matplotlib._qhull' not in sys.modules
assert 'matplotlib._contour' not in sys.modules
assert 'urllib.request' not in sys.modules
""")
subprocess.check_call(
[sys.executable, '-c', source],
env={**os.environ, "MPLBACKEND": "", "MATPLOTLIBRC": os.devnull})