예제 #1
0
    def test_bound_env(self):
        from plumbum.cmd import printenv

        with local.env(FOO = "hello"):
            assert printenv.with_env(BAR = "world")("FOO") == "hello\n"
            assert printenv.with_env(BAR = "world")("BAR") == "world\n"
            assert printenv.with_env(FOO = "sea", BAR = "world")("FOO") == "sea\n"
            assert printenv("FOO") == "hello\n"
예제 #2
0
 def test_bound_env(self):
     try:
         from plumbum.cmd import printenv
     except CommandNotFound:
         self.skipTest("printenv is missing")
     with local.env(FOO = "hello"):
         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")
예제 #3
0
 def test_bound_env(self):
     try:
         from plumbum.cmd import printenv
     except CommandNotFound:
         self.skipTest("printenv is missing")
     with local.env(FOO="hello"):
         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")
예제 #4
0
    def test_bound_env(self):
        from plumbum.cmd import printenv

        with local.env(FOO="hello"):
            assert printenv.with_env(BAR="world")("FOO") == "hello\n"
            assert printenv.with_env(BAR="world")("BAR") == "world\n"
            assert printenv.with_env(FOO="sea", BAR="world")("FOO") == "sea\n"
            assert printenv("FOO") == "hello\n"

        assert local.cmd.pwd.with_cwd("/")() == "/\n"
        assert local.cmd.pwd["-L"].with_env(A="X").with_cwd("/")() == "/\n"