eric7/DebugClients/Python/coverage/env.py

branch
eric7
changeset 8312
800c432b34c8
parent 7975
7d493839a8fc
child 8527
2bd1325d727e
equal deleted inserted replaced
8311:4e8b98454baa 8312:800c432b34c8
1 # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
2 # For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt
3
4 """Determine facts about the environment."""
5
6 import os
7 import platform
8 import sys
9
10 # Operating systems.
11 WINDOWS = sys.platform == "win32"
12 LINUX = sys.platform.startswith("linux")
13
14 # Python versions. We amend version_info with one more value, a zero if an
15 # official version, or 1 if built from source beyond an official version.
16 PYVERSION = sys.version_info + (int(platform.python_version()[-1] == "+"),)
17 PY2 = PYVERSION < (3, 0)
18 PY3 = PYVERSION >= (3, 0)
19
20 # Python implementations.
21 PYPY = (platform.python_implementation() == 'PyPy')
22 if PYPY:
23 PYPYVERSION = sys.pypy_version_info
24
25 PYPY2 = PYPY and PY2
26 PYPY3 = PYPY and PY3
27
28 JYTHON = (platform.python_implementation() == 'Jython')
29 IRONPYTHON = (platform.python_implementation() == 'IronPython')
30
31 # Python behavior
32 class PYBEHAVIOR(object):
33 """Flags indicating this Python's behavior."""
34
35 # Is "if __debug__" optimized away?
36 optimize_if_debug = (not PYPY)
37
38 # Is "if not __debug__" optimized away?
39 optimize_if_not_debug = (not PYPY) and (PYVERSION >= (3, 7, 0, 'alpha', 4))
40
41 # Is "if not __debug__" optimized away even better?
42 optimize_if_not_debug2 = (not PYPY) and (PYVERSION >= (3, 8, 0, 'beta', 1))
43
44 # Do we have yield-from?
45 yield_from = (PYVERSION >= (3, 3))
46
47 # Do we have PEP 420 namespace packages?
48 namespaces_pep420 = (PYVERSION >= (3, 3))
49
50 # Do .pyc files have the source file size recorded in them?
51 size_in_pyc = (PYVERSION >= (3, 3))
52
53 # Do we have async and await syntax?
54 async_syntax = (PYVERSION >= (3, 5))
55
56 # PEP 448 defined additional unpacking generalizations
57 unpackings_pep448 = (PYVERSION >= (3, 5))
58
59 # Can co_lnotab have negative deltas?
60 negative_lnotab = (PYVERSION >= (3, 6)) and not (PYPY and PYPYVERSION < (7, 2))
61
62 # Do .pyc files conform to PEP 552? Hash-based pyc's.
63 hashed_pyc_pep552 = (PYVERSION >= (3, 7, 0, 'alpha', 4))
64
65 # Python 3.7.0b3 changed the behavior of the sys.path[0] entry for -m. It
66 # used to be an empty string (meaning the current directory). It changed
67 # to be the actual path to the current directory, so that os.chdir wouldn't
68 # affect the outcome.
69 actual_syspath0_dash_m = (not PYPY) and (PYVERSION >= (3, 7, 0, 'beta', 3))
70
71 # When a break/continue/return statement in a try block jumps to a finally
72 # block, does the finally block do the break/continue/return (pre-3.8), or
73 # does the finally jump back to the break/continue/return (3.8) to do the
74 # work?
75 finally_jumps_back = (PYVERSION >= (3, 8))
76
77 # When a function is decorated, does the trace function get called for the
78 # @-line and also the def-line (new behavior in 3.8)? Or just the @-line
79 # (old behavior)?
80 trace_decorated_def = (PYVERSION >= (3, 8))
81
82 # Are while-true loops optimized into absolute jumps with no loop setup?
83 nix_while_true = (PYVERSION >= (3, 8))
84
85 # Python 3.9a1 made sys.argv[0] and other reported files absolute paths.
86 report_absolute_files = (PYVERSION >= (3, 9))
87
88 # Coverage.py specifics.
89
90 # Are we using the C-implemented trace function?
91 C_TRACER = os.getenv('COVERAGE_TEST_TRACER', 'c') == 'c'
92
93 # Are we coverage-measuring ourselves?
94 METACOV = os.getenv('COVERAGE_COVERAGE', '') != ''
95
96 # Are we running our test suite?
97 # Even when running tests, you can use COVERAGE_TESTING=0 to disable the
98 # test-specific behavior like contracts.
99 TESTING = os.getenv('COVERAGE_TESTING', '') == 'True'

eric ide

mercurial