Skip to content

Commit

Permalink
add check for env variables in test
Browse files Browse the repository at this point in the history
  • Loading branch information
Elias Werner committed Oct 8, 2024
1 parent 7a2da1f commit 1a6613f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 4 additions & 4 deletions tests/kernel/writemode.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 6 additions & 2 deletions tests/test_kernel.py
Original file line number Diff line number Diff line change
@@ -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/"

Expand All @@ -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
Expand All @@ -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)

Expand Down

0 comments on commit 1a6613f

Please sign in to comment.