File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -1435,9 +1435,12 @@ The :mod:`test.support.os_helper` module provides support for os tests.
14351435 ``value ``.
14361436
14371437
1438- .. method :: EnvironmentVarGuard.unset(envvar)
1438+ .. method :: EnvironmentVarGuard.unset(envvar, *others )
14391439
1440- Temporarily unset the environment variable ``envvar ``.
1440+ Temporarily unset one or more environment variables.
1441+
1442+ .. versionchanged :: next
1443+ More than one environment variable can be unset.
14411444
14421445
14431446.. function :: can_symlink()
Original file line number Diff line number Diff line change @@ -720,9 +720,10 @@ def temp_umask(umask):
720720
721721
722722class EnvironmentVarGuard (collections .abc .MutableMapping ):
723+ """Class to help protect the environment variable properly.
723724
724- """Class to help protect the environment variable properly. Can be used as
725- a context manager. """
725+ Can be used as a context manager.
726+ """
726727
727728 def __init__ (self ):
728729 self ._environ = os .environ
@@ -756,8 +757,10 @@ def __len__(self):
756757 def set (self , envvar , value ):
757758 self [envvar ] = value
758759
759- def unset (self , envvar ):
760- del self [envvar ]
760+ def unset (self , envvar , / , * envvars ):
761+ """Unset one or more known environment variables."""
762+ for ev in (envvar , * envvars ):
763+ del self [ev ]
761764
762765 def copy (self ):
763766 # We do what os.environ.copy() does.
You can’t perform that action at this time.
0 commit comments