-
Notifications
You must be signed in to change notification settings - Fork 506
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for script files, Python and Julia (py|jl)
- Loading branch information
1 parent
34718a2
commit 1dd4300
Showing
7 changed files
with
116 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,44 @@ | ||
# test serving a notebook | ||
# test serving a notebook or python/julia file | ||
import os | ||
import pytest | ||
|
||
TEST_JULIA = os.environ.get('VOILA_TEST_JULIA', '') == '1' | ||
|
||
|
||
@pytest.fixture | ||
def voila_args(notebook_directory, voila_args_extra): | ||
return ['--VoilaTest.root_dir=%r' % notebook_directory, '--VoilaTest.log_level=DEBUG'] + voila_args_extra | ||
|
||
|
||
@pytest.mark.gen_test | ||
def test_hello_world(http_client, print_notebook_url): | ||
def test_print(http_client, print_notebook_url): | ||
print(print_notebook_url) | ||
response = yield http_client.fetch(print_notebook_url) | ||
assert response.code == 200 | ||
assert 'Hi Voila' in response.body.decode('utf-8') | ||
|
||
|
||
@pytest.mark.gen_test | ||
def test_print_py(http_client, print_notebook_url): | ||
print(print_notebook_url) | ||
response = yield http_client.fetch(print_notebook_url.replace('ipynb', 'py')) | ||
assert response.code == 200 | ||
assert 'Hi Voila' in response.body.decode('utf-8') | ||
|
||
|
||
@pytest.mark.skipif(not TEST_JULIA, reason='testing julia is slow and requires external dependencies') | ||
@pytest.mark.gen_test | ||
def test_print_julia(http_client, print_notebook_url): | ||
print(print_notebook_url) | ||
response = yield http_client.fetch(print_notebook_url.replace('ipynb', 'jl')) | ||
assert response.code == 200 | ||
assert 'Hi Voila, from Julia' in response.body.decode('utf-8') | ||
|
||
|
||
@pytest.mark.skipif(not TEST_JULIA, reason='testing julia is slow and requires external dependencies') | ||
@pytest.mark.gen_test | ||
def test_print_julia_notebook(http_client, print_notebook_url): | ||
print(print_notebook_url) | ||
response = yield http_client.fetch(print_notebook_url.replace('.ipynb', '_julia.ipynb')) | ||
assert response.code == 200 | ||
assert 'Hi Voila, from Julia' in response.body.decode('utf-8') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# --- | ||
# jupyter: | ||
# jupytext: | ||
# text_representation: | ||
# extension: .jl | ||
# format_name: light | ||
# format_version: '1.4' | ||
# jupytext_version: 1.2.1 | ||
# kernelspec: | ||
# display_name: Julia 1.0.3 | ||
# language: julia | ||
# name: julia-1.0 | ||
# --- | ||
|
||
print("Hi Voila, from Julia") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# --- | ||
# jupyter: | ||
# jupytext: | ||
# text_representation: | ||
# extension: .py | ||
# format_name: light | ||
# format_version: '1.4' | ||
# jupytext_version: 1.2.1 | ||
# kernelspec: | ||
# display_name: Python 3 | ||
# language: python | ||
# name: python | ||
# --- | ||
|
||
print('Hi Voila!') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"print(\"Hi Voila, from Julia!\")" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Julia 1.0.3", | ||
"language": "julia", | ||
"name": "julia-1.0" | ||
}, | ||
"language_info": { | ||
"file_extension": ".jl", | ||
"mimetype": "application/julia", | ||
"name": "julia", | ||
"version": "1.0.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters