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

Class MockNTNamespace

Lib/test/test_getpath.py:941–1049  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

939)
940
941class MockNTNamespace(dict):
942 def __init__(self, *a, argv0=None, config=None, **kw):
943 self.update(DEFAULT_NAMESPACE)
944 self["config"] = DEFAULT_CONFIG.copy()
945 self["os_name"] = "nt"
946 self["PLATLIBDIR"] = "DLLs"
947 self["PYWINVER"] = "9.8-XY"
948 self["VPATH"] = r"..\.."
949 super().__init__(*a, **kw)
950 if argv0:
951 self["config"]["orig_argv"] = [argv0]
952 if config:
953 self["config"].update(config)
954 self._files = {}
955 self._links = {}
956 self._dirs = set()
957 self._warnings = []
958
959 def add_known_file(self, path, lines=None):
960 self._files[path.casefold()] = list(lines or ())
961 self.add_known_dir(path.rpartition("\\")[0])
962
963 def add_known_xfile(self, path):
964 self.add_known_file(path)
965
966 def add_known_link(self, path, target):
967 self._links[path.casefold()] = target
968
969 def add_known_dir(self, path):
970 p = path.rstrip("\\").casefold()
971 while p:
972 self._dirs.add(p)
973 p = p.rpartition("\\")[0]
974
975 def __missing__(self, key):
976 try:
977 return getattr(self, key)
978 except AttributeError:
979 raise KeyError(key) from None
980
981 def abspath(self, path):
982 if self.isabs(path):
983 return path
984 return self.joinpath("C:\\Absolute", path)
985
986 def basename(self, path):
987 return path.rpartition("\\")[2]
988
989 def dirname(self, path):
990 name = path.rstrip("\\").rpartition("\\")[0]
991 if name[1:] == ":":
992 return name + "\\"
993 return name
994
995 def hassuffix(self, path, suffix):
996 return path.casefold().endswith(suffix.casefold())
997
998 def isabs(self, path):

Callers 8

test_normal_win32Method · 0.85
test_buildtree_win32Method · 0.85
test_venv_win32Method · 0.85
test_registry_win32Method · 0.85
test_no_dlls_win32Method · 0.85

Calls

no outgoing calls

Tested by 8

test_normal_win32Method · 0.68
test_buildtree_win32Method · 0.68
test_venv_win32Method · 0.68
test_registry_win32Method · 0.68
test_no_dlls_win32Method · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…