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

        self.assertFileExists('pipe_commands.out')
        self.assertFileHasContent('pipe_commands.out', 'spam')
Ejemplo n.º 2
0
    def test_it_works_when_large_amounts_of_data_are_being_piped(self):
        pipe_commands([
            ['echo', r"""
import sys
for i in range(400000):
    sys.stdout.write('spam\n')
"""],
            ['python'],
            ['tee', 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')
Ejemplo n.º 3
0
    def test_it_pipes_a_list_of_commands_into_each_other(self):
        pipe_commands([
            ['echo', r"""
import sys
for i in range(4):
    sys.stdout.write('spam\n')
"""],
            ['python'],
            ['tee', self.get_path('pipe_commands.out')],
        ])

        self.assertFileExists('pipe_commands.out')
        self.assertFileHasContent(
            'pipe_commands.out',
            'spam\nspam\nspam\nspam\n',
        )
Ejemplo n.º 4
0
    def test_it_works_when_large_amounts_of_data_are_being_piped(self):
        pipe_commands([
            [
                'echo', r"""
import sys
for i in range(400000):
    sys.stdout.write('spam\n')
"""
            ],
            ['python'],
            ['tee', 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')
Ejemplo n.º 5
0
    def test_it_allows_you_to_specify_extra_environment_variables(self):
        pipe_commands([
            [
                'echo', """
import os
import sys
sys.stdout.write(os.environ['TEST_VAR'])
"""
            ],
            ['python'],
            ['tee', self.get_path('pipe_commands.out')],
        ],
                      extra_env={'TEST_VAR': 'spam'})

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

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