@@ -86,7 +86,7 @@ def abs_path(v):
8686 try :
8787 __import__ ("venv" )
8888 has = True
89- except ImportError :
89+ except ImportError : # pragma: no cover # venv is always available in standard CPython
9090 has = False
9191 self .has_venv = has
9292 self .path = sys .path
@@ -105,14 +105,14 @@ def abs_path(v):
105105 # debian / ubuntu python 3.10 without `python3-distutils` will report
106106 # mangled `local/bin` / etc. names for the default prefix
107107 # intentionally select `posix_prefix` which is the unaltered posix-like paths
108- elif sys .version_info [:2 ] == (3 , 10 ) and "deb_system" in scheme_names :
108+ elif sys .version_info [:2 ] == (3 , 10 ) and "deb_system" in scheme_names : # pragma: no cover # Debian/Ubuntu 3.10
109109 self .sysconfig_scheme = "posix_prefix"
110110 self .sysconfig_paths = {
111111 i : sysconfig .get_path (i , expand = False , scheme = self .sysconfig_scheme ) for i in sysconfig .get_path_names ()
112112 }
113113 # we cannot use distutils at all if "venv" exists, distutils don't know it
114114 self .distutils_install = {}
115- else :
115+ else : # pragma: no cover # "venv" scheme always present on Python 3.12+
116116 self .sysconfig_scheme = None
117117 self .sysconfig_paths = {i : sysconfig .get_path (i , expand = False ) for i in sysconfig .get_path_names ()}
118118 self .distutils_install = self ._distutils_install ().copy ()
@@ -151,7 +151,7 @@ def abs_path(v):
151151 self ._creators = None # virtualenv-specific, set via monkey-patch
152152
153153 @staticmethod
154- def _get_tcl_tk_libs ():
154+ def _get_tcl_tk_libs (): # pragma: no cover # tkinter availability varies; tested indirectly via __init__
155155 """Detects the tcl and tk libraries using tkinter.
156156
157157 This works reliably but spins up tkinter, which is heavy if you don't need it.
@@ -266,7 +266,7 @@ def install_path(self, key: str) -> str:
266266
267267 """
268268 result = self .distutils_install .get (key )
269- if result is None : # use sysconfig if sysconfig_scheme is set or distutils is unavailable
269+ if result is None : # pragma: no branch # distutils is empty when "venv" scheme is available
270270 # set prefixes to empty => result is relative from cwd
271271 prefixes = self .prefix , self .exec_prefix , self .base_prefix , self .base_exec_prefix
272272 config_var = {k : "" if v in prefixes else v for k , v in self .sysconfig_vars .items ()}
@@ -287,11 +287,11 @@ def _distutils_install():
287287 from distutils .command .install import ( # ty: ignore[unresolved-import]
288288 SCHEME_KEYS ,
289289 )
290- except ImportError : # if removed or not installed ignore
290+ except ImportError : # pragma: no cover # if removed or not installed ignore
291291 return {}
292292
293293 d = dist .Distribution ({"script_args" : "--no-user-cfg" }) # conf files not parsed so they do not hijack paths
294- if hasattr (sys , "_framework" ):
294+ if hasattr (sys , "_framework" ): # pragma: no cover # macOS framework builds only
295295 sys ._framework = None # disable macOS static paths for framework
296296
297297 with warnings .catch_warnings (): # disable warning for PEP-632
@@ -359,8 +359,7 @@ def system_include(self) -> str:
359359 for k , v in self .sysconfig_vars .items ()
360360 },
361361 )
362- if not os .path .exists (path ): # some broken packaging don't respect the sysconfig, fallback to distutils path
363- # the pattern include the distribution name too at the end, remove that via the parent call
362+ if not os .path .exists (path ): # pragma: no cover # broken packaging fallback
364363 fallback = os .path .join (self .prefix , os .path .dirname (self .install_path ("headers" )))
365364 if os .path .exists (fallback ):
366365 path = fallback
@@ -502,7 +501,7 @@ def satisfies(self, spec: PythonSpec, impl_must_match: bool) -> bool:
502501 "beta" : "b" ,
503502 "candidate" : "rc" ,
504503 }.get (version_info .releaselevel )
505- if suffix is not None :
504+ if suffix is not None : # pragma: no branch # releaselevel is always alpha/beta/candidate here
506505 release = f"{ release } { suffix } { version_info .serial } "
507506 if not spec .version_specifier .contains (release ):
508507 return False
0 commit comments