Skip to content

Commit 4ee4f2b

Browse files
authored
Remove explicit utf-8 from decode() as it's default (#2237)
1 parent 8fc97cb commit 4ee4f2b

File tree

8 files changed

+16
-16
lines changed

8 files changed

+16
-16
lines changed

tagging/utils/docker_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def run_simple_command(
4848
) -> str:
4949
LOGGER.info(f"Running cmd: '{cmd}' on container: {container}")
5050
out = container.exec_run(cmd)
51-
result = out.output.decode("utf-8").rstrip()
51+
result = out.output.decode().rstrip()
5252
assert isinstance(result, str)
5353
if print_result:
5454
LOGGER.info(f"Command result: {result}")

tests/image_specific_tests/base-notebook/test_container_options.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def test_cli_args(container: TrackedContainer, http_client: requests.Session) ->
2121
)
2222
resp = http_client.get(f"http://localhost:{host_port}")
2323
resp.raise_for_status()
24-
logs = running_container.logs().decode("utf-8")
24+
logs = running_container.logs().decode()
2525
LOGGER.debug(logs)
2626
assert "ERROR" not in logs
2727
warnings = TrackedContainer.get_warnings(logs)
@@ -48,7 +48,7 @@ def test_nb_user_change(container: TrackedContainer) -> None:
4848
command = f'stat -c "%F %U %G" /home/{nb_user}/.jupyter'
4949
expected_output = f"directory {nb_user} users"
5050
cmd = running_container.exec_run(command, workdir=f"/home/{nb_user}")
51-
output = cmd.output.decode("utf-8").strip("\n")
51+
output = cmd.output.decode().strip("\n")
5252
assert (
5353
output == expected_output
5454
), 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(
7474
resp = http_client.get(f"https://localhost:{host_port}", verify=False)
7575
resp.raise_for_status()
7676
assert "login_submit" in resp.text
77-
logs = running_container.logs().decode("utf-8")
77+
logs = running_container.logs().decode()
7878
assert "ERROR" not in logs
7979
warnings = TrackedContainer.get_warnings(logs)
8080
assert not warnings
@@ -109,7 +109,7 @@ def test_custom_internal_port(
109109
)
110110
resp = http_client.get(f"http://localhost:{host_port}")
111111
resp.raise_for_status()
112-
logs = running_container.logs().decode("utf-8")
112+
logs = running_container.logs().decode()
113113
LOGGER.debug(logs)
114114
assert "ERROR" not in logs
115115
warnings = TrackedContainer.get_warnings(logs)

tests/image_specific_tests/base-notebook/test_start_container.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def test_start_notebook(
4949
)
5050
# sleeping some time to let the server start
5151
time.sleep(2)
52-
logs = running_container.logs().decode("utf-8")
52+
logs = running_container.logs().decode()
5353
LOGGER.debug(logs)
5454
# checking that the expected command is launched
5555
assert (
@@ -79,7 +79,7 @@ def test_tini_entrypoint(
7979
running_container = container.run_detached(tty=True)
8080
# Select the PID 1 and get the corresponding command
8181
cmd = running_container.exec_run(f"ps -p {pid} -o comm=")
82-
output = cmd.output.decode("utf-8").strip("\n")
82+
output = cmd.output.decode().strip("\n")
8383
assert "ERROR" not in output
8484
assert "WARNING" not in output
8585
assert output == command, f"{command} shall be launched as pid {pid}, got {output}"

tests/image_specific_tests/docker-stacks-foundation/test_packages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def _check_import_package(
115115
"""Generic function executing a command"""
116116
LOGGER.debug(f"Trying to import a package with [{command}] ...")
117117
exec_result = package_helper.running_container.exec_run(command)
118-
assert exec_result.exit_code == 0, exec_result.output.decode("utf-8")
118+
assert exec_result.exit_code == 0, exec_result.output.decode()
119119

120120

121121
def check_import_python_package(

tests/image_specific_tests/docker-stacks-foundation/test_user_options.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def test_nb_user_change(container: TrackedContainer) -> None:
5050
# Use sleep, not wait, because the container sleeps forever.
5151
time.sleep(1)
5252
LOGGER.info(f"Checking if the user is changed to {nb_user} by the start script ...")
53-
output = running_container.logs().decode("utf-8")
53+
output = running_container.logs().decode()
5454
assert "ERROR" not in output
5555
assert "WARNING" not in output
5656
assert (
@@ -61,14 +61,14 @@ def test_nb_user_change(container: TrackedContainer) -> None:
6161
command = "id"
6262
expected_output = f"uid=1000({nb_user}) gid=100(users) groups=100(users)"
6363
cmd = running_container.exec_run(command, user=nb_user, workdir=f"/home/{nb_user}")
64-
output = cmd.output.decode("utf-8").strip("\n")
64+
output = cmd.output.decode().strip("\n")
6565
assert output == expected_output, f"Bad user {output}, expected {expected_output}"
6666

6767
LOGGER.info(f"Checking if {nb_user} owns his home folder ...")
6868
command = f'stat -c "%U %G" /home/{nb_user}/'
6969
expected_output = f"{nb_user} users"
7070
cmd = running_container.exec_run(command, workdir=f"/home/{nb_user}")
71-
output = cmd.output.decode("utf-8").strip("\n")
71+
output = cmd.output.decode().strip("\n")
7272
assert (
7373
output == expected_output
7474
), 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:
7979
command = f'stat -c "%F %U %G" /home/{nb_user}/work'
8080
expected_output = f"directory {nb_user} users"
8181
cmd = running_container.exec_run(command, workdir=f"/home/{nb_user}")
82-
output = cmd.output.decode("utf-8").strip("\n")
82+
output = cmd.output.decode().strip("\n")
8383
assert (
8484
output == expected_output
8585
), f"Folder work was not copied properly to {nb_user} home folder. stat: {output}, expected {expected_output}"

tests/image_specific_tests/scipy-notebook/test_matplotlib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ def test_matplotlib(
4545
)
4646
command = f"python {cont_data_dir}/{test_file}"
4747
cmd = running_container.exec_run(command)
48-
LOGGER.debug(cmd.output.decode("utf-8"))
48+
LOGGER.debug(cmd.output.decode())
4949
assert cmd.exit_code == 0, f"Command {command} failed"
5050
# Checking if the file is generated
5151
# https://stackoverflow.com/a/15895594/4413446
5252
command = f"test -s {output_dir}/{expected_file}"
5353
cmd = running_container.exec_run(command)
54-
LOGGER.debug(cmd.output.decode("utf-8"))
54+
LOGGER.debug(cmd.output.decode())
5555
assert cmd.exit_code == 0, f"Command {command} failed"

tests/utils/conda_package_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def requested_packages(self) -> dict[str, set[str]]:
9191
def _execute_command(self, command: list[str]) -> str:
9292
"""Execute a command on a running container"""
9393
rc = self.running_container.exec_run(command, stderr=False)
94-
return rc.output.decode("utf-8") # type: ignore
94+
return rc.output.decode() # type: ignore
9595

9696
@staticmethod
9797
def _parse_package_versions(env_export: str) -> dict[str, set[str]]:

tests/utils/tracked_container.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def run_and_wait(
7070
) -> str:
7171
running_container = self.run_detached(**kwargs)
7272
rv = running_container.wait(timeout=timeout)
73-
logs = running_container.logs().decode("utf-8")
73+
logs = running_container.logs().decode()
7474
assert isinstance(logs, str)
7575
LOGGER.debug(logs)
7676
assert no_warnings == (not self.get_warnings(logs))

0 commit comments

Comments
 (0)