Exemplo n.º 1
0
    def test_it_allows_you_to_specify_extra_environment_variables(self):
        pipe_commands_to_file([
            ['echo', """
import os
import sys
sys.stdout.write(os.environ['TEST_VAR'])
"""],
            ['python'],
        ], self.get_path('pipe_commands.out'), extra_env={'TEST_VAR': 'spam'})

        self.assertFileExists('pipe_commands.out')
        self.assertFileHasContent('pipe_commands.out', 'spam')
Exemplo n.º 2
0
    def test_it_works_when_large_amounts_of_data_are_being_piped(self):
        pipe_commands_to_file([
            ['echo', r"""
import sys
for i in range(400000):
    sys.stdout.write('spam\n')
"""],
            ['python'],
        ], self.get_path('pipe_commands.out'))

        self.assertFileExists('pipe_commands.out')
        self.assertFileHasLength('pipe_commands.out', 2000000)
        self.assertInFile('pipe_commands.out', 'spam\nspam\nspam\n')
Exemplo n.º 3
0
    def test_it_pipes_a_list_of_commands_into_each_other_and_then_into_a_file(self):
        pipe_commands_to_file([
            ['echo', r"""
import sys
for i in range(4):
    sys.stdout.write('spam\n')
"""],
            ['python'],
        ], self.get_path('pipe_commands.out'))

        self.assertFileExists('pipe_commands.out')
        self.assertFileHasContent(
            'pipe_commands.out',
            'spam\nspam\nspam\nspam\n',
        )
Exemplo n.º 4
0
    def test_it_works_when_large_amounts_of_data_are_being_piped(self):
        pipe_commands_to_file([
            [
                'echo', r"""
import sys
for i in range(400000):
    sys.stdout.write('spam\n')
"""
            ],
            ['python'],
        ], self.get_path('pipe_commands.out'))

        self.assertFileExists('pipe_commands.out')
        self.assertFileHasLength('pipe_commands.out', 2000000)
        self.assertInFile('pipe_commands.out', 'spam\nspam\nspam\n')
Exemplo n.º 5
0
    def test_it_allows_you_to_specify_extra_environment_variables(self):
        pipe_commands_to_file([
            [
                'echo', """
import os
import sys
sys.stdout.write(os.environ['TEST_VAR'])
"""
            ],
            ['python'],
        ],
                              self.get_path('pipe_commands.out'),
                              extra_env={'TEST_VAR': 'spam'})

        self.assertFileExists('pipe_commands.out')
        self.assertFileHasContent('pipe_commands.out', 'spam')
Exemplo n.º 6
0
    def test_it_pipes_a_list_of_commands_into_each_other_and_then_into_a_file(
            self):
        pipe_commands_to_file([
            [
                'echo', r"""
import sys
for i in range(4):
    sys.stdout.write('spam\n')
"""
            ],
            ['python'],
        ], self.get_path('pipe_commands.out'))

        self.assertFileExists('pipe_commands.out')
        self.assertFileHasContent(
            'pipe_commands.out',
            'spam\nspam\nspam\nspam\n',
        )