##// END OF EJS Templates
remove utils.doctestreload...
remove utils.doctestreload it's unused, and its docstring suggests that it's obsolete on all currently supported Pythons.

File last commit:

r20951:706daf38
r21076:a160d671
Show More
test_kernelspec.py
64 lines | 2.6 KiB | text/x-python | PythonLexer
Thomas Kluyver
Add simple tests for kernel spec machinery
r16478 import json
import os
from os.path import join as pjoin
import unittest
Thomas Kluyver
Add test for installing kernel spec
r16562 from IPython.testing.decorators import onlyif
Thomas Kluyver
Add simple tests for kernel spec machinery
r16478 from IPython.utils.tempdir import TemporaryDirectory
Min RK
s/IPython.kernel/jupyter_client in jupyter_client
r20951 from jupyter_client import kernelspec
Thomas Kluyver
Add simple tests for kernel spec machinery
r16478
sample_kernel_json = {'argv':['cat', '{connection_file}'],
'display_name':'Test kernel',
}
class KernelSpecTests(unittest.TestCase):
def setUp(self):
Thomas Kluyver
Add test for installing kernel spec
r16562 td = TemporaryDirectory()
self.addCleanup(td.cleanup)
Thomas Kluyver
Add simple tests for kernel spec machinery
r16478 self.sample_kernel_dir = pjoin(td.name, 'kernels', 'Sample')
os.makedirs(self.sample_kernel_dir)
json_file = pjoin(self.sample_kernel_dir, 'kernel.json')
with open(json_file, 'w') as f:
json.dump(sample_kernel_json, f)
self.ksm = kernelspec.KernelSpecManager(ipython_dir=td.name)
Min RK
move client code from IPython.kernel to jupyter_client
r20949
Thomas Kluyver
Add test for installing kernel spec
r16562 td2 = TemporaryDirectory()
self.addCleanup(td2.cleanup)
self.installable_kernel = td2.name
with open(pjoin(self.installable_kernel, 'kernel.json'), 'w') as f:
json.dump(sample_kernel_json, f)
Thomas Kluyver
Add simple tests for kernel spec machinery
r16478
def test_find_kernel_specs(self):
kernels = self.ksm.find_kernel_specs()
self.assertEqual(kernels['sample'], self.sample_kernel_dir)
def test_get_kernel_spec(self):
ks = self.ksm.get_kernel_spec('SAMPLE') # Case insensitive
self.assertEqual(ks.resource_dir, self.sample_kernel_dir)
self.assertEqual(ks.argv, sample_kernel_json['argv'])
self.assertEqual(ks.display_name, sample_kernel_json['display_name'])
Thomas Kluyver
Add test for installing kernel spec
r16562 self.assertEqual(ks.env, {})
Min RK
move client code from IPython.kernel to jupyter_client
r20949
Thomas Kluyver
Add test for installing kernel spec
r16562 def test_install_kernel_spec(self):
self.ksm.install_kernel_spec(self.installable_kernel,
Thomas Kluyver
Update kernelspec tests
r19524 kernel_name='tstinstalled',
user=True)
Thomas Kluyver
Add test for installing kernel spec
r16562 self.assertIn('tstinstalled', self.ksm.find_kernel_specs())
Min RK
move client code from IPython.kernel to jupyter_client
r20949
Thomas Kluyver
Add test for installing kernel spec
r16562 with self.assertRaises(OSError):
self.ksm.install_kernel_spec(self.installable_kernel,
Thomas Kluyver
Update kernelspec tests
r19524 kernel_name='tstinstalled',
user=True)
Min RK
move client code from IPython.kernel to jupyter_client
r20949
Thomas Kluyver
Add test for installing kernel spec
r16562 # Smoketest that this succeeds
self.ksm.install_kernel_spec(self.installable_kernel,
kernel_name='tstinstalled',
Thomas Kluyver
Update kernelspec tests
r19524 replace=True, user=True)
Thomas Kluyver
Revert change to test skip condition...
r19593 @onlyif(os.name != 'nt' and not os.access('/usr/local/share', os.W_OK), "needs Unix system without root privileges")
Thomas Kluyver
Add test for installing kernel spec
r16562 def test_cant_install_kernel_spec(self):
with self.assertRaises(OSError):
self.ksm.install_kernel_spec(self.installable_kernel,
kernel_name='tstinstalled',
Thomas Kluyver
Update kernelspec tests
r19524 user=False)