Skip to content

Commit

Permalink
Merge pull request #291 from scrapinghub/notebook-tests
Browse files Browse the repository at this point in the history
TST basic tests for splash.kernel
  • Loading branch information
kmike committed Sep 4, 2015
2 parents 181f697 + ab24d3b commit 85ff32b
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ virtualenv:
before_install:
- sudo apt-get install python-twisted python-qt4 lua5.2-dev zlib1g-dev python-imaging
- pip install -U qt4reactor psutil requests jsonschema strict-rfc3339 xvfbwrapper pytest funcparserlib pytest-cov codecov
- "if [[ $SYSTEM_PACKAGES == 'false' ]]; then pip install -UI Pillow twisted service_identity lupa; fi"
- "if [[ $SYSTEM_PACKAGES == 'false' ]]; then pip install -UI Pillow twisted service_identity lupa jupyter_kernel_test nose ipython[notebook]; fi"

install:
- python setup.py install
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ requests >= 1.0
jsonschema >= 2.0
strict-rfc3339
pytest-cov
jupyter_kernel_test
nose
ipython[notebook]
3 changes: 2 additions & 1 deletion splash/kernel/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ class SplashKernel(Kernel):
"name": "text/x-lua",
},
'file_extension': '.lua',
'pygments_lexer': 'lua'
'pygments_lexer': 'lua',
'version': get_version(),
}
banner = "Splash kernel - write browser automation scripts interactively"
help_links = [
Expand Down
54 changes: 54 additions & 0 deletions splash/tests/test_jupyter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import

import pytest
jupyter_kernel_test = pytest.importorskip("jupyter_kernel_test")
lupa = pytest.importorskip("lupa")


class SplashKernelTest(jupyter_kernel_test.KernelTests):

@classmethod
def setUpClass(cls):
# XXX: this installs kernel spec to global user environment,
# not to a virtualenv.
from splash.kernel import kernel
kernel.install()

super(SplashKernelTest, cls).setUpClass()

# The name identifying an installed kernel to run the tests against
kernel_name = "splash"

# language_info.name in a kernel_info_reply should match this
language_name = "Splash"

# Optional --------------------------------------
# Code in the kernel's language to write "hello, world" to stdout
# code_hello_world = "print 'hello, world'"

# Tab completions: in each dictionary, text is the input, which it will
# try to complete from the end of. matches is the collection of results
# it should expect.
completion_samples = [
{
'text': 'spl',
'matches': {'splash'},
},
{
'text': 'splash:eva',
'matches': {'evaljs'},
},
{
'text': 'splash.ar',
'matches': {'args'},
},
]

# Code completeness: samples grouped by expected result
# complete_code_samples = ['x=2']
# incomplete_code_samples = ['function foo(', '"""in a string']
# invalid_code_samples = ['x=2a']

# # Pager: code that should display something (anything) in the pager
# code_page_something = "help('foldl')"

0 comments on commit 85ff32b

Please sign in to comment.