File tree 2 files changed +14
-4
lines changed
2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 9
9
10
10
from typing import Any , Iterable , Tuple
11
11
12
+ # debug_info() at the bottom wants to show all the globals, but not imports.
13
+ # Grab the global names here to know which names to not show. Nothing defined
14
+ # above this line will be in the output.
15
+ _UNINTERESTING_GLOBALS = list (globals ())
16
+ # These names also shouldn't be shown.
17
+ _UNINTERESTING_GLOBALS += ["PYBEHAVIOR" , "debug_info" ]
18
+
12
19
# Operating systems.
13
20
WINDOWS = sys .platform == "win32"
14
21
LINUX = sys .platform .startswith ("linux" )
@@ -140,10 +147,7 @@ def debug_info() -> Iterable[Tuple[str, Any]]:
140
147
"""Return a list of (name, value) pairs for printing debug information."""
141
148
info = [
142
149
(name , value ) for name , value in globals ().items ()
143
- if not name .startswith ("_" ) and
144
- name not in {"PYBEHAVIOR" , "debug_info" } and
145
- not isinstance (value , type (os )) and
146
- not str (value ).startswith ("typing." )
150
+ if not name .startswith ("_" ) and name not in _UNINTERESTING_GLOBALS
147
151
]
148
152
info += [
149
153
(name , value ) for name , value in PYBEHAVIOR .__dict__ .items ()
Original file line number Diff line number Diff line change @@ -318,6 +318,12 @@ def test_debug_pybehave(self) -> None:
318
318
assert " CPYTHON:" in out
319
319
assert " PYVERSION:" in out
320
320
assert " pep626:" in out
321
+
322
+ # Some things that shouldn't appear..
323
+ assert "typing." not in out # import from typing
324
+ assert ": <" not in out # objects without a good repr
325
+
326
+ # It should report PYVERSION correctly.
321
327
pyversion = re_line (r" PYVERSION:" , out )
322
328
vtuple = ast .literal_eval (pyversion .partition (":" )[- 1 ].strip ())
323
329
assert vtuple [:5 ] == sys .version_info
You can’t perform that action at this time.
0 commit comments