style: apply black via pre-commit run -a
This commit is contained in:
committed by
Henry Schreiner
parent
9cbed6a9be
commit
178aaea6c7
@@ -38,7 +38,12 @@ def test_no_lf():
|
||||
@pytest.mark.docker
|
||||
def test_environment():
|
||||
with DockerContainer(DEFAULT_IMAGE) as container:
|
||||
assert container.call(['sh', '-c', 'echo $TEST_VAR'], env={'TEST_VAR': '1'}, capture_output=True) == '1\n'
|
||||
assert (
|
||||
container.call(
|
||||
['sh', '-c', 'echo $TEST_VAR'], env={'TEST_VAR': '1'}, capture_output=True
|
||||
)
|
||||
== '1\n'
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.docker
|
||||
@@ -51,28 +56,43 @@ def test_cwd():
|
||||
@pytest.mark.docker
|
||||
def test_container_removed():
|
||||
with DockerContainer(DEFAULT_IMAGE) as container:
|
||||
docker_containers_listing = subprocess.run('docker container ls', shell=True, check=True, stdout=subprocess.PIPE, universal_newlines=True).stdout
|
||||
docker_containers_listing = subprocess.run(
|
||||
'docker container ls',
|
||||
shell=True,
|
||||
check=True,
|
||||
stdout=subprocess.PIPE,
|
||||
universal_newlines=True,
|
||||
).stdout
|
||||
assert container.name in docker_containers_listing
|
||||
old_container_name = container.name
|
||||
|
||||
docker_containers_listing = subprocess.run('docker container ls', shell=True, check=True, stdout=subprocess.PIPE, universal_newlines=True).stdout
|
||||
docker_containers_listing = subprocess.run(
|
||||
'docker container ls',
|
||||
shell=True,
|
||||
check=True,
|
||||
stdout=subprocess.PIPE,
|
||||
universal_newlines=True,
|
||||
).stdout
|
||||
assert old_container_name not in docker_containers_listing
|
||||
|
||||
|
||||
@pytest.mark.docker
|
||||
def test_large_environment():
|
||||
# max environment variable size is 128kB
|
||||
long_env_var_length = 127*1024
|
||||
long_env_var_length = 127 * 1024
|
||||
large_environment = {
|
||||
'a': '0'*long_env_var_length,
|
||||
'b': '0'*long_env_var_length,
|
||||
'c': '0'*long_env_var_length,
|
||||
'd': '0'*long_env_var_length,
|
||||
'a': '0' * long_env_var_length,
|
||||
'b': '0' * long_env_var_length,
|
||||
'c': '0' * long_env_var_length,
|
||||
'd': '0' * long_env_var_length,
|
||||
}
|
||||
|
||||
with DockerContainer(DEFAULT_IMAGE) as container:
|
||||
# check the length of d
|
||||
assert container.call(['sh', '-c', 'echo ${#d}'], env=large_environment, capture_output=True) == f'{long_env_var_length}\n'
|
||||
assert (
|
||||
container.call(['sh', '-c', 'echo ${#d}'], env=large_environment, capture_output=True)
|
||||
== f'{long_env_var_length}\n'
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.docker
|
||||
@@ -81,16 +101,33 @@ def test_binary_output():
|
||||
# note: the below embedded snippets are in python2
|
||||
|
||||
# check that we can pass though arbitrary binary data without erroring
|
||||
container.call(['/usr/bin/python2', '-c', textwrap.dedent('''
|
||||
container.call(
|
||||
[
|
||||
'/usr/bin/python2',
|
||||
'-c',
|
||||
textwrap.dedent(
|
||||
'''
|
||||
import sys
|
||||
sys.stdout.write(''.join(chr(n) for n in range(0, 256)))
|
||||
''')])
|
||||
'''
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
# check that we can capture arbitrary binary data
|
||||
output = container.call(['/usr/bin/python2', '-c', textwrap.dedent('''
|
||||
output = container.call(
|
||||
[
|
||||
'/usr/bin/python2',
|
||||
'-c',
|
||||
textwrap.dedent(
|
||||
'''
|
||||
import sys
|
||||
sys.stdout.write(''.join(chr(n % 256) for n in range(0, 512)))
|
||||
''')], capture_output=True)
|
||||
'''
|
||||
),
|
||||
],
|
||||
capture_output=True,
|
||||
)
|
||||
|
||||
data = bytes(output, encoding='utf8', errors='surrogateescape')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user