-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathtest_spylon_kernel_jkt.py
59 lines (45 loc) · 1.6 KB
/
test_spylon_kernel_jkt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""Example use of jupyter_kernel_test, with tests for IPython."""
import unittest
import jupyter_kernel_test
from spylon_kernel.scala_interpreter import init_spark
from textwrap import dedent
class SpylonKernelTests(jupyter_kernel_test.KernelTests):
kernel_name = "spylon-kernel"
language_name = "scala"
# code_hello_world = "disp('hello, world')"
completion_samples = [
{'text': 'val x = 8; x.toL',
'matches': {'x.toLong'}},
]
code_page_something = "x?"
code_hello_world = '''
println("hello, world")
// Sleep for a bit since the process for getting text output is asynchronous
Thread.sleep(1000)
'''
code_stderr = '''
Console.err.println("oh noes!")
// Sleep for a bit since the process for getting text output is asynchronous
Thread.sleep(1000)
'''
complete_code_samples = ['val y = 8']
incomplete_code_samples = ['{ val foo = 9 ']
invalid_code_samples = ['val {}']
code_generate_error = "4 / 0"
code_execute_result = [{
'code': 'val x = 1',
'result': 'x: Int = 1\n'
}, {
'code': 'val y = 1 to 3',
'result': 'y: scala.collection.immutable.Range.Inclusive = Range(1, 2, 3)\n'
}]
spark_configured = False
def setUp(self):
"""Set up to capture stderr for testing purposes."""
super(SpylonKernelTests, self).setUp()
self.flush_channels()
if not self.spark_configured:
self.execute_helper(code='%%init_spark --stderr')
self.spark_configured = True
if __name__ == '__main__':
unittest.main()