예제 #1
0
    def test_repr(self):
        """
        A user should be able to run str(Subprocess) in their shell prompt.
        """
        cmd_str = str(run('printf', 'foo"bar'))
        output = subprocess.check_output(cmd_str, shell=True).decode()

        assert output == 'foo"bar'
예제 #2
0
    def test_repr(self):
        """
        A user should be able to run str(Subprocess) in their shell prompt.
        """
        cmd_str = str(run('printf', 'foo"bar'))
        output = subprocess.check_output(cmd_str, shell=True).decode()

        assert output == 'foo"bar'
예제 #3
0
    def test_empty_env(self):
        proc = run('env', env={'foo': 'bar'})

        spm_run = set(proc.stdout.read().decode().split('\n'))
        sh_run = set(
            subprocess.check_output(str(proc), shell=True).decode().split('\n')
        )

        assert sh_run == spm_run
예제 #4
0
    def test_empty_env(self):
        proc = run('env', env={'foo': 'bar'})

        spm_run = set(proc.stdout.read().decode().split('\n'))
        sh_run = set(
            subprocess.check_output(str(proc),
                                    shell=True).decode().split('\n'))

        assert sh_run == spm_run
예제 #5
0
    def test_stdin_from_file(self):
        content = '__file_content__'

        fname = self.get_temp_filename()
        with open(fname, 'w') as file_:
            file_.write(content)

        cat = run('cat')
        cat.stdin = open(fname)

        assert cat.stdout.read().decode() == content
예제 #6
0
    def test_stdin_from_file(self):
        content = '__file_content__'

        fname = self.get_temp_filename()
        with open(fname, 'w') as file_:
            file_.write(content)

        cat = run('cat')
        cat.stdin = open(fname)

        assert cat.stdout.read().decode() == content
예제 #7
0
    def test_stdout_to_file(self):
        string = '__output__'
        fname = self.get_temp_filename()

        echo = run('printf', string)
        echo.stdout = open(fname, 'w')
        out, err = echo.wait()

        assert out is None

        with open(fname) as file_:
            assert six.u(file_.read()) == string
예제 #8
0
    def test_stdout_to_file(self):
        string = '__output__'
        fname = self.get_temp_filename()

        echo = run('printf', string)
        echo.stdout = open(fname, 'w')
        out, err = echo.wait()

        assert out is None

        with open(fname) as file_:
            assert six.u(file_.read()) == string
예제 #9
0
 def test_pass_subprocess_to_pipe(self):
     proc = pipe(['printf', 'hello'], ['gzip'], run('zcat'))
     assert proc.stdout.read().decode() == 'hello'
예제 #10
0
 def test_subprocess_failure(self):
     with self.assertRaises(subprocess.CalledProcessError):
         run('false').wait()
예제 #11
0
    def test_repr_env(self):
        cmd_str = str(run('env', env={'FOO': 'BAR'}))
        env = subprocess.check_output(cmd_str, shell=True).decode().split('\n')

        assert 'FOO=BAR' in env
예제 #12
0
    def test_empty_environment_by_default(self):
        env = run('env').stdout.read().decode()

        assert env == ''
예제 #13
0
    def test_empty_environment_by_default(self):
        env = run('env').stdout.read().decode()

        assert env == ''
예제 #14
0
    def test_environment(self):
        env = run('env', env={'FOO': 'BAR'}).stdout.read().decode().split('\n')

        assert 'FOO=BAR' in env
예제 #15
0
 def test_pass_subprocess_to_pipe(self):
     proc = pipe(['printf', 'hello'], ['gzip'], run('zcat'))
     assert proc.stdout.read().decode() == 'hello'
예제 #16
0
 def test_subprocess_failure(self):
     with self.assertRaises(subprocess.CalledProcessError):
         run('false').wait()
예제 #17
0
    def test_environment(self):
        env = run('env', env={'FOO': 'BAR'}).stdout.read().decode().split('\n')

        assert 'FOO=BAR' in env
예제 #18
0
    def test_copy_environment_opt_in(self):
        env = run('env', env=propagate_env({})).stdout.read().decode()

        assert env != ''
예제 #19
0
    def test_copy_environment_opt_in(self):
        env = run('env', env=propagate_env({})).stdout.read().decode()

        assert env != ''
예제 #20
0
    def test_repr_env(self):
        cmd_str = str(run('env', env=propagate_env(foo='bar')))
        env = subprocess.check_output(cmd_str, shell=True).decode().split('\n')

        assert 'foo=bar' in env
예제 #21
0
    def test_repr_env(self):
        cmd_str = str(run('env', env=propagate_env(foo='bar')))
        env = subprocess.check_output(cmd_str, shell=True).decode().split('\n')

        assert 'foo=bar' in env
예제 #22
0
    def test_empty_environment(self):
        env = run('env', env=empty_environ()).stdout.read().decode()

        assert env == ''