diff --git a/plumbum/commands/base.py b/plumbum/commands/base.py index 80709add..0cd3ed2b 100644 --- a/plumbum/commands/base.py +++ b/plumbum/commands/base.py @@ -92,12 +92,14 @@ def __call__(self, *args, **kwargs): def _get_encoding(self): raise NotImplementedError() - def setenv(self, **envvars): - """Creates a BoundEnvCommand with the given environment variables""" + def with_env(self, **envvars): + """Returns a BoundEnvCommand with the given environment variables""" if not envvars: return self return BoundEnvCommand(self, envvars) + setenv = with_env + @property def machine(self): raise NotImplementedError() diff --git a/tests/test_local.py b/tests/test_local.py index a4601139..a62dd7da 100644 --- a/tests/test_local.py +++ b/tests/test_local.py @@ -406,8 +406,8 @@ def test_bound_env(self): except CommandNotFound: self.skipTest("printenv is missing") with local.env(FOO = "hello"): - self.assertEqual(printenv.setenv(BAR = "world")("FOO", "BAR"), "hello\nworld\n") - self.assertEqual(printenv.setenv(FOO = "sea", BAR = "world")("FOO", "BAR"), "sea\nworld\n") + self.assertEqual(printenv.with_env(BAR = "world")("FOO", "BAR"), "hello\nworld\n") + self.assertEqual(printenv.with_env(FOO = "sea", BAR = "world")("FOO", "BAR"), "sea\nworld\n") def test_nesting_lists_as_argv(self): from plumbum.cmd import ls diff --git a/tests/test_remote.py b/tests/test_remote.py index 701519c9..a02ad33e 100644 --- a/tests/test_remote.py +++ b/tests/test_remote.py @@ -180,8 +180,8 @@ def test_bound_env(self): with self._connect() as rem: printenv = rem["printenv"] with rem.env(FOO = "hello"): - self.assertEqual(printenv.setenv(BAR = "world")("FOO", "BAR"), "hello\nworld\n") - self.assertEqual(printenv.setenv(FOO = "sea", BAR = "world")("FOO", "BAR"), "sea\nworld\n") + self.assertEqual(printenv.with_env(BAR = "world")("FOO", "BAR"), "hello\nworld\n") + self.assertEqual(printenv.with_env(FOO = "sea", BAR = "world")("FOO", "BAR"), "sea\nworld\n") def test_sshpass(self): with local.as_root():