mirror of
https://github.com/jupyter/docker-stacks.git
synced 2025-10-07 01:54:04 +00:00
Remove explicit utf-8 from decode() as it's default (#2237)
This commit is contained in:
@@ -48,7 +48,7 @@ class DockerRunner:
|
||||
) -> str:
|
||||
LOGGER.info(f"Running cmd: '{cmd}' on container: {container}")
|
||||
out = container.exec_run(cmd)
|
||||
result = out.output.decode("utf-8").rstrip()
|
||||
result = out.output.decode().rstrip()
|
||||
assert isinstance(result, str)
|
||||
if print_result:
|
||||
LOGGER.info(f"Command result: {result}")
|
||||
|
@@ -21,7 +21,7 @@ def test_cli_args(container: TrackedContainer, http_client: requests.Session) ->
|
||||
)
|
||||
resp = http_client.get(f"http://localhost:{host_port}")
|
||||
resp.raise_for_status()
|
||||
logs = running_container.logs().decode("utf-8")
|
||||
logs = running_container.logs().decode()
|
||||
LOGGER.debug(logs)
|
||||
assert "ERROR" not in logs
|
||||
warnings = TrackedContainer.get_warnings(logs)
|
||||
@@ -48,7 +48,7 @@ def test_nb_user_change(container: TrackedContainer) -> None:
|
||||
command = f'stat -c "%F %U %G" /home/{nb_user}/.jupyter'
|
||||
expected_output = f"directory {nb_user} users"
|
||||
cmd = running_container.exec_run(command, workdir=f"/home/{nb_user}")
|
||||
output = cmd.output.decode("utf-8").strip("\n")
|
||||
output = cmd.output.decode().strip("\n")
|
||||
assert (
|
||||
output == expected_output
|
||||
), f"Hidden folder .jupyter was not copied properly to {nb_user} home folder. stat: {output}, expected {expected_output}"
|
||||
@@ -74,7 +74,7 @@ def test_unsigned_ssl(
|
||||
resp = http_client.get(f"https://localhost:{host_port}", verify=False)
|
||||
resp.raise_for_status()
|
||||
assert "login_submit" in resp.text
|
||||
logs = running_container.logs().decode("utf-8")
|
||||
logs = running_container.logs().decode()
|
||||
assert "ERROR" not in logs
|
||||
warnings = TrackedContainer.get_warnings(logs)
|
||||
assert not warnings
|
||||
@@ -109,7 +109,7 @@ def test_custom_internal_port(
|
||||
)
|
||||
resp = http_client.get(f"http://localhost:{host_port}")
|
||||
resp.raise_for_status()
|
||||
logs = running_container.logs().decode("utf-8")
|
||||
logs = running_container.logs().decode()
|
||||
LOGGER.debug(logs)
|
||||
assert "ERROR" not in logs
|
||||
warnings = TrackedContainer.get_warnings(logs)
|
||||
|
@@ -49,7 +49,7 @@ def test_start_notebook(
|
||||
)
|
||||
# sleeping some time to let the server start
|
||||
time.sleep(2)
|
||||
logs = running_container.logs().decode("utf-8")
|
||||
logs = running_container.logs().decode()
|
||||
LOGGER.debug(logs)
|
||||
# checking that the expected command is launched
|
||||
assert (
|
||||
@@ -79,7 +79,7 @@ def test_tini_entrypoint(
|
||||
running_container = container.run_detached(tty=True)
|
||||
# Select the PID 1 and get the corresponding command
|
||||
cmd = running_container.exec_run(f"ps -p {pid} -o comm=")
|
||||
output = cmd.output.decode("utf-8").strip("\n")
|
||||
output = cmd.output.decode().strip("\n")
|
||||
assert "ERROR" not in output
|
||||
assert "WARNING" not in output
|
||||
assert output == command, f"{command} shall be launched as pid {pid}, got {output}"
|
||||
|
@@ -115,7 +115,7 @@ def _check_import_package(
|
||||
"""Generic function executing a command"""
|
||||
LOGGER.debug(f"Trying to import a package with [{command}] ...")
|
||||
exec_result = package_helper.running_container.exec_run(command)
|
||||
assert exec_result.exit_code == 0, exec_result.output.decode("utf-8")
|
||||
assert exec_result.exit_code == 0, exec_result.output.decode()
|
||||
|
||||
|
||||
def check_import_python_package(
|
||||
|
@@ -50,7 +50,7 @@ def test_nb_user_change(container: TrackedContainer) -> None:
|
||||
# Use sleep, not wait, because the container sleeps forever.
|
||||
time.sleep(1)
|
||||
LOGGER.info(f"Checking if the user is changed to {nb_user} by the start script ...")
|
||||
output = running_container.logs().decode("utf-8")
|
||||
output = running_container.logs().decode()
|
||||
assert "ERROR" not in output
|
||||
assert "WARNING" not in output
|
||||
assert (
|
||||
@@ -61,14 +61,14 @@ def test_nb_user_change(container: TrackedContainer) -> None:
|
||||
command = "id"
|
||||
expected_output = f"uid=1000({nb_user}) gid=100(users) groups=100(users)"
|
||||
cmd = running_container.exec_run(command, user=nb_user, workdir=f"/home/{nb_user}")
|
||||
output = cmd.output.decode("utf-8").strip("\n")
|
||||
output = cmd.output.decode().strip("\n")
|
||||
assert output == expected_output, f"Bad user {output}, expected {expected_output}"
|
||||
|
||||
LOGGER.info(f"Checking if {nb_user} owns his home folder ...")
|
||||
command = f'stat -c "%U %G" /home/{nb_user}/'
|
||||
expected_output = f"{nb_user} users"
|
||||
cmd = running_container.exec_run(command, workdir=f"/home/{nb_user}")
|
||||
output = cmd.output.decode("utf-8").strip("\n")
|
||||
output = cmd.output.decode().strip("\n")
|
||||
assert (
|
||||
output == expected_output
|
||||
), f"Bad owner for the {nb_user} home folder {output}, expected {expected_output}"
|
||||
@@ -79,7 +79,7 @@ def test_nb_user_change(container: TrackedContainer) -> None:
|
||||
command = f'stat -c "%F %U %G" /home/{nb_user}/work'
|
||||
expected_output = f"directory {nb_user} users"
|
||||
cmd = running_container.exec_run(command, workdir=f"/home/{nb_user}")
|
||||
output = cmd.output.decode("utf-8").strip("\n")
|
||||
output = cmd.output.decode().strip("\n")
|
||||
assert (
|
||||
output == expected_output
|
||||
), f"Folder work was not copied properly to {nb_user} home folder. stat: {output}, expected {expected_output}"
|
||||
|
@@ -45,11 +45,11 @@ def test_matplotlib(
|
||||
)
|
||||
command = f"python {cont_data_dir}/{test_file}"
|
||||
cmd = running_container.exec_run(command)
|
||||
LOGGER.debug(cmd.output.decode("utf-8"))
|
||||
LOGGER.debug(cmd.output.decode())
|
||||
assert cmd.exit_code == 0, f"Command {command} failed"
|
||||
# Checking if the file is generated
|
||||
# https://stackoverflow.com/a/15895594/4413446
|
||||
command = f"test -s {output_dir}/{expected_file}"
|
||||
cmd = running_container.exec_run(command)
|
||||
LOGGER.debug(cmd.output.decode("utf-8"))
|
||||
LOGGER.debug(cmd.output.decode())
|
||||
assert cmd.exit_code == 0, f"Command {command} failed"
|
||||
|
@@ -91,7 +91,7 @@ class CondaPackageHelper:
|
||||
def _execute_command(self, command: list[str]) -> str:
|
||||
"""Execute a command on a running container"""
|
||||
rc = self.running_container.exec_run(command, stderr=False)
|
||||
return rc.output.decode("utf-8") # type: ignore
|
||||
return rc.output.decode() # type: ignore
|
||||
|
||||
@staticmethod
|
||||
def _parse_package_versions(env_export: str) -> dict[str, set[str]]:
|
||||
|
@@ -70,7 +70,7 @@ class TrackedContainer:
|
||||
) -> str:
|
||||
running_container = self.run_detached(**kwargs)
|
||||
rv = running_container.wait(timeout=timeout)
|
||||
logs = running_container.logs().decode("utf-8")
|
||||
logs = running_container.logs().decode()
|
||||
assert isinstance(logs, str)
|
||||
LOGGER.debug(logs)
|
||||
assert no_warnings == (not self.get_warnings(logs))
|
||||
|
Reference in New Issue
Block a user