MCPcopy Index your code
hub / github.com/RustPython/RustPython / get_excepted_output

Method get_excepted_output

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

Source from the content-addressed store, hash-verified

819 return "doesn't exist"
820
821 def get_excepted_output(self, *args):
822 if len(args) == 0:
823 user_base = site.getuserbase()
824 user_site = site.getusersitepackages()
825 output = io.StringIO()
826 output.write("sys.path = [\n")
827 for dir in sys.path:
828 output.write(" %r,\n" % (dir,))
829 output.write("]\n")
830 output.write(f"USER_BASE: {user_base} ({self.exists(user_base)})\n")
831 output.write(f"USER_SITE: {user_site} ({self.exists(user_site)})\n")
832 output.write(f"ENABLE_USER_SITE: {site.ENABLE_USER_SITE}\n")
833 return 0, dedent(output.getvalue()).strip()
834
835 buffer = []
836 if '--user-base' in args:
837 buffer.append(site.getuserbase())
838 if '--user-site' in args:
839 buffer.append(site.getusersitepackages())
840
841 if buffer:
842 return_code = 3
843 if site.ENABLE_USER_SITE:
844 return_code = 0
845 elif site.ENABLE_USER_SITE is False:
846 return_code = 1
847 elif site.ENABLE_USER_SITE is None:
848 return_code = 2
849 output = os.pathsep.join(buffer)
850 return return_code, os.path.normpath(dedent(output).strip())
851 else:
852 return 10, None
853
854 def invoke_command_line(self, *args):
855 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 8

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

Tested by

no test coverage detected