Skip to content

Commit

Permalink
Merge pull request #143 from AntoineD/master
Browse files Browse the repository at this point in the history
fix issue #136
  • Loading branch information
tomerfiliba committed Aug 7, 2014
2 parents b2be5a2 + 5c47239 commit c6f65bd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions plumbum/commands/base.py
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_local.py
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/test_remote.py
Expand Up @@ -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():
Expand Down

0 comments on commit c6f65bd

Please sign in to comment.