@pytest.mark.docker
def test_binary_output():
    with DockerContainer(DEFAULT_IMAGE) as container:
        container.call(['/usr/bin/python2', '-c', textwrap.dedent("\n                    import sys\n                    sys.stdout.write(''.join(chr(n) for n in range(0, 256)))\n                    ")])
        output = container.call(['/usr/bin/python2', '-c', textwrap.dedent("\n                    import sys\n                    sys.stdout.write(''.join(chr(n % 256) for n in range(0, 512)))\n                    ")], capture_output=True)
        data = bytes(output, encoding='utf8', errors='surrogateescape')
        for i in range(512):
            assert (data[i] == (i % 256))
        binary_data = bytes((n for n in range(1, 256)))
        binary_data_string = str(binary_data, encoding='utf8', errors='surrogateescape')
        output = container.call(['python2', '-c', 'import os, sys; sys.stdout.write(os.environ["TEST_VAR"])'], env={'TEST_VAR': binary_data_string}, capture_output=True)
        assert (output == binary_data_string)
@pytest.mark.docker
def test_binary_output():
    with DockerContainer(DEFAULT_IMAGE) as container:
        container.call(['/usr/bin/python2', '-c', textwrap.dedent("\n                    import sys\n                    sys.stdout.write(.join(chr(n) for n in range(0, 256)))\n                    ")])
        output = container.call(['/usr/bin/python2', '-c', textwrap.dedent("\n                    import sys\n                    sys.stdout.write(.join(chr(n % 256) for n in range(0, 512)))\n                    ")], capture_output=True)
        data = bytes(output, encoding='utf8', errors='surrogateescape')
        for i in range(512):
            assert (data[i] == (i % 256))
        binary_data = bytes((n for n in range(1, 256)))
        binary_data_string = str(binary_data, encoding='utf8', errors='surrogateescape')
        output = container.call(['python2', '-c', 'import os, sys; sys.stdout.write(os.environ["TEST_VAR"])'], env={'TEST_VAR': binary_data_string}, capture_output=True)
        assert (output == binary_data_string)