MCPcopy Index your code
hub / github.com/python/cpython / get_excepted_output

Method get_excepted_output

Lib/test/test_site.py:813–844  ·  view source on GitHub ↗
(self, *args)

Source from the content-addressed store, hash-verified

811 return "doesn't exist"
812
813 def get_excepted_output(self, *args):
814 if len(args) == 0:
815 user_base = site.getuserbase()
816 user_site = site.getusersitepackages()
817 output = io.StringIO()
818 output.write("sys.path = [\n")
819 for dir in sys.path:
820 output.write(" %r,\n" % (dir,))
821 output.write("]\n")
822 output.write(f"USER_BASE: {user_base} ({self.exists(user_base)})\n")
823 output.write(f"USER_SITE: {user_site} ({self.exists(user_site)})\n")
824 output.write(f"ENABLE_USER_SITE: {site.ENABLE_USER_SITE}\n")
825 return 0, dedent(output.getvalue()).strip()
826
827 buffer = []
828 if '--user-base' in args:
829 buffer.append(site.getuserbase())
830 if '--user-site' in args:
831 buffer.append(site.getusersitepackages())
832
833 if buffer:
834 return_code = 3
835 if site.ENABLE_USER_SITE:
836 return_code = 0
837 elif site.ENABLE_USER_SITE is False:
838 return_code = 1
839 elif site.ENABLE_USER_SITE is None:
840 return_code = 2
841 output = os.pathsep.join(buffer)
842 return return_code, os.path.normpath(dedent(output).strip())
843 else:
844 return 10, None
845
846 def invoke_command_line(self, *args):
847 cmd_args = []

Callers 5

test_no_argsMethod · 0.95
test_unknown_argsMethod · 0.95
test_base_argMethod · 0.95
test_site_argMethod · 0.95
test_both_argsMethod · 0.95

Calls 7

existsMethod · 0.95
getvalueMethod · 0.95
dedentFunction · 0.90
writeMethod · 0.45
stripMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected