Skip to content

Commit

Permalink
test windows
Browse files Browse the repository at this point in the history
  • Loading branch information
WolframAlph committed Jan 4, 2025
1 parent 3c56fbf commit 3c48465
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Lib/test/support/os_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,16 +701,23 @@ def __init__(self):
self._environ = os.environ
self._changed = {}

def _convert(self, envvar):
if os.name == "nt":
return envvar.upper()
return envvar

def __getitem__(self, envvar):
return self._environ[envvar]
return self._environ[self._convert(envvar)]

def __setitem__(self, envvar, value):
# Remember the initial value on the first access
envvar = self._convert(envvar)
if envvar not in self._changed:
self._changed[envvar] = self._environ.get(envvar)
self._environ[envvar] = value

def __delitem__(self, envvar):
envvar = self._convert(envvar)
# Remember the initial value on the first access
if envvar not in self._changed:
self._changed[envvar] = self._environ.get(envvar)
Expand All @@ -727,10 +734,10 @@ def __len__(self):
return len(self._environ)

def set(self, envvar, value):
self[envvar] = value
self[self._convert(envvar)] = value

def unset(self, envvar):
del self[envvar]
del self[self._convert(envvar)]

def copy(self):
# We do what os.environ.copy() does.
Expand Down

0 comments on commit 3c48465

Please sign in to comment.