12
12
import nbformat
13
13
import papermill as pm
14
14
15
- class XCppCompleteTests (jupyter_kernel_test .KernelTests ):
16
-
17
- kernel_name = 'xcpp20'
18
-
15
+ class BaseXCppCompleteTests (jupyter_kernel_test .KernelTests ):
16
+ __test__ = False
17
+
19
18
# language_info.name in a kernel_info_reply should match this
20
19
language_name = 'C++'
21
20
@@ -64,12 +63,22 @@ def test_continuation(self) -> None:
64
63
self .assertEqual (str (reply ["content" ]["indent" ]), "" )
65
64
self .assertEqual (reply ["content" ]["status" ], "complete" )
66
65
66
+ kernel_names = ['xcpp17' , 'xcpp20' , 'xcpp23' ]
67
67
68
- if platform .system () != 'Windows' :
69
- class XCppTests (jupyter_kernel_test .KernelTests ):
70
-
71
- kernel_name = 'xcpp20'
68
+ for name in kernel_names :
69
+ class_name = f"XCppCompleteTests_{ name } "
70
+ globals ()[class_name ] = type (
71
+ class_name ,
72
+ (BaseXCppCompleteTests ,),
73
+ {
74
+ 'kernel_name' : name ,
75
+ '__test__' : True
76
+ }
77
+ )
72
78
79
+ if platform .system () != 'Windows' :
80
+ class BaseXCppTests (jupyter_kernel_test .KernelTests ):
81
+ __test__ = False
73
82
# language_info.name in a kernel_info_reply should match this
74
83
language_name = 'C++'
75
84
@@ -130,9 +139,20 @@ class XCppTests(jupyter_kernel_test.KernelTests):
130
139
}
131
140
]
132
141
133
- # Tests for Notebooks
134
- class XCppNotebookTests (unittest .TestCase ):
142
+ for name in kernel_names :
143
+ class_name = f"XCppTests_{ name } "
144
+ globals ()[class_name ] = type (
145
+ class_name ,
146
+ (BaseXCppTests ,),
147
+ {
148
+ 'kernel_name' : name ,
149
+ '__test__' : True
150
+ }
151
+ )
135
152
153
+ # Tests for Notebooks
154
+ class BaseXCppNotebookTests (unittest .TestCase ):
155
+ __test__ = False
136
156
notebook_names = [
137
157
'xeus-cpp'
138
158
# Add more notebook names as needed
@@ -153,7 +173,7 @@ def test_notebooks(self):
153
173
inp ,
154
174
out ,
155
175
log_output = True ,
156
- kernel_name = 'xcpp20'
176
+ kernel_name = self . kernel_name
157
177
)
158
178
159
179
if executed_notebook is None : # Explicit check for None or any other condition
@@ -174,17 +194,36 @@ def test_notebooks(self):
174
194
if input_cell .outputs != output_cell .outputs :
175
195
self .fail (f"{ input_output .get ('text' )} != { output_output .get ('text' )} Cell { i } in notebook { name } has mismatched output type" )
176
196
197
+ for name in kernel_names :
198
+ class_name = f"XCppNotebookTests_{ name } "
199
+ globals ()[class_name ] = type (
200
+ class_name ,
201
+ (BaseXCppNotebookTests ,),
202
+ {
203
+ 'kernel_name' : name ,
204
+ '__test__' : True
205
+ }
206
+ )
177
207
178
- class XCppTests2 (jupyter_kernel_test .KernelTests ):
179
-
180
- kernel_name = 'xcpp20'
208
+ class BaseXCppTests2 (jupyter_kernel_test .KernelTests ):
209
+ __test__ = False
181
210
182
211
# language_info.name in a kernel_info_reply should match this
183
212
language_name = 'C++'
184
213
185
214
# Code that should write the exact string `hello, world` to STDOUT
186
215
code_hello_world = '#include <stdio.h>\n printf("hello, world");'
187
216
217
+ for name in kernel_names :
218
+ class_name = f"XCppTests2_{ name } "
219
+ globals ()[class_name ] = type (
220
+ class_name ,
221
+ (BaseXCppTests2 ,),
222
+ {
223
+ 'kernel_name' : name ,
224
+ '__test__' : True
225
+ }
226
+ )
188
227
189
228
if __name__ == '__main__' :
190
- unittest .main ()
229
+ unittest .main ()
0 commit comments