From 1a6613fc9637ebcf28af32bd0af8a3819d7059b1 Mon Sep 17 00:00:00 2001 From: Elias Werner Date: Tue, 8 Oct 2024 13:03:49 +0200 Subject: [PATCH] add check for env variables in test --- tests/kernel/writemode.yaml | 8 ++++---- tests/test_kernel.py | 8 ++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/kernel/writemode.yaml b/tests/kernel/writemode.yaml index ad76608..b07c83e 100644 --- a/tests/kernel/writemode.yaml +++ b/tests/kernel/writemode.yaml @@ -2,8 +2,8 @@ - "%%start_writefile" - - | Started converting to Python script. See files: - /home/runner/work/scorep_jupyter_kernel_python/jupyter_to_script_run.sh - /home/runner/work/scorep_jupyter_kernel_python/jupyter_to_script.py + ${PWD}/jupyter_to_script_run.sh + ${PWD}/jupyter_to_script.py - - |- %env SCOREP_ENABLE_TRACING=1 @@ -18,8 +18,8 @@ - "%%start_writefile test_kernel_tmp/my_jupyter_to_script" - - | Started converting to Python script. See files: - /home/runner/work/scorep_jupyter_kernel_python/test_kernel_tmp/my_jupyter_to_script_run.sh - /home/runner/work/scorep_jupyter_kernel_python/test_kernel_tmp/my_jupyter_to_script.py + ${PWD}/test_kernel_tmp/my_jupyter_to_script_run.sh + ${PWD}/test_kernel_tmp/my_jupyter_to_script.py - - |- %env SCOREP_ENABLE_TRACING=1 diff --git a/tests/test_kernel.py b/tests/test_kernel.py index 9476345..7bd0584 100644 --- a/tests/test_kernel.py +++ b/tests/test_kernel.py @@ -1,7 +1,7 @@ import unittest import jupyter_kernel_test as jkt -import os -import yaml +import yaml, re, os + tmp_dir = "test_kernel_tmp/" @@ -28,6 +28,8 @@ def check_stream_output(self, code, expected_output, stream="stdout"): self.flush_channels() reply, output_msgs = self.execute_helper(code=code) for msg, expected_msg in zip(output_msgs, expected_output): + # replace env vars + expected_msg = os.path.expandvars(expected_msg) # self.assertEqual(msg["header"]["msg_type"], "stream") # some messages can be of type 'execute_result' # type instead of stdout @@ -41,8 +43,10 @@ def check_stream_output(self, code, expected_output, stream="stdout"): ) def check_from_file(self, filename): + with open(filename, "r") as file: cells = yaml.safe_load(file) + for code, expected_output in cells: self.check_stream_output(code, expected_output)