def test1(self): with interim_environ(ocrodjvu='42'): child = ipc.Subprocess( ['sh', '-c', 'printf $ocrodjvu'], stdout=ipc.PIPE, stderr=ipc.PIPE, ) stdout, stderr = child.communicate() assert_equal(stdout, '42') assert_equal(stderr, '')
def test_path(self): path = os.getenv('PATH').split(':') with temporary.directory() as tmpdir: command_name = temporary.name(dir=tmpdir) command_path = os.path.join(tmpdir, command_name) with open(command_path, 'wt') as file: print('#!/bin/sh', file=file) print('printf 42', file=file) os.chmod(command_path, stat.S_IRWXU) path[:0] = [tmpdir] path = ':'.join(path) with interim_environ(PATH=path): child = ipc.Subprocess([command_name], stdout=ipc.PIPE, stderr=ipc.PIPE, ) stdout, stderr = child.communicate() assert_equal(stdout, '42') assert_equal(stderr, '')
def test_path(self): path = os.getenv('PATH').split(':') with temporary.directory() as tmpdir: command_name = temporary.name(dir=tmpdir) command_path = os.path.join(tmpdir, command_name) with open(command_path, 'wt') as file: print('#!/bin/sh', file=file) print('printf 42', file=file) os.chmod(command_path, stat.S_IRWXU) path[:0] = [tmpdir] path = ':'.join(path) with interim_environ(PATH=path): child = ipc.Subprocess( [command_name], stdout=ipc.PIPE, stderr=ipc.PIPE, ) stdout, stderr = child.communicate() assert_equal(stdout, '42') assert_equal(stderr, '')
def test_locale_lang(self): with interim_environ(LC_ALL=None, LC_CTYPE=None, LANG='en_US.UTF-8'): self._test_locale()
def test_locale_lc_ctype(self): with interim_environ(LC_ALL=None, LC_CTYPE='en_US.UTF-8'): self._test_locale()
def test_locale_lc_all(self): with interim_environ(LC_ALL='en_US.UTF-8'): self._test_locale()