Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Thomas Gambier
slapos
Commits
9220fe4e
Commit
9220fe4e
authored
Jan 05, 2023
by
Léo-Paul Géneau
👾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
software/jupyter: Test IPython
parent
ff5b29c0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
5 deletions
+70
-5
component/jupyter/buildout.cfg
component/jupyter/buildout.cfg
+5
-5
software/jupyter/test/test.py
software/jupyter/test/test.py
+65
-0
No files found.
component/jupyter/buildout.cfg
View file @
9220fe4e
...
...
@@ -69,7 +69,6 @@ scripts =
pythonjupyter
jupyter
jupyter-trust
jupyter-nbconvert
jupyter-console
jupyter-migrate
jupyter-troubleshoot
...
...
@@ -81,6 +80,7 @@ eggs = ${jupyter:eggs}
environment = jupyter-env
scripts =
jupyter-nbconvert
jupyter-nbextension
jupyter-notebook
jupyter-serverextension
...
...
software/jupyter/test/test.py
View file @
9220fe4e
...
...
@@ -31,6 +31,7 @@ import json
import
os
import
requests
import
sqlite3
import
subprocess
from
slapos.proxy.db_version
import
DB_VERSION
from
slapos.testing.testcase
import
makeModuleSetUpAndTestCaseClass
...
...
@@ -268,3 +269,67 @@ class TestJupyterCustomAdditional(SelectMixin, InstanceTestCase):
# clean up the fake master
r
.
destroyed
()
class
TestIPython
(
InstanceTestCase
):
converted_notebook
=
'test.nbconvert.ipynb'
notebook_filename
=
'test.ipynb'
test_sentence
=
'test'
def
setUp
(
self
):
super
().
setUp
()
notebook_source
=
{
"cells"
:
[
{
"cell_type"
:
"code"
,
"execution_count"
:
None
,
"metadata"
:
{},
"outputs"
:
[],
"source"
:
[
"import sys
\
n
"
,
"print('"
+
self
.
test_sentence
+
"')"
]
}
],
"metadata"
:
{},
"nbformat"
:
4
,
"nbformat_minor"
:
4
}
with
open
(
self
.
notebook_filename
,
'w'
)
as
notebook
:
notebook
.
write
(
json
.
dumps
(
notebook_source
))
def
tearDown
(
self
):
os
.
remove
(
self
.
notebook_filename
)
if
os
.
path
.
exists
(
self
.
converted_notebook
):
os
.
remove
(
self
.
converted_notebook
)
super
().
tearDown
()
def
test
(
self
):
conversion_output
=
subprocess
.
check_output
([
os
.
path
.
join
(
self
.
computer_partition_root_path
,
'software_release'
,
'bin'
,
'jupyter-nbconvert'
,
),
'--execute'
,
'--to'
,
'notebook'
,
self
.
notebook_filename
,
],
stderr
=
subprocess
.
STDOUT
,
text
=
True
)
self
.
assertIn
(
'[NbConvertApp] Converting notebook %s to notebook'
%
self
.
notebook_filename
,
conversion_output
,
)
self
.
assertRegex
(
conversion_output
,
r'\
[N
bConvertApp\
] W
riting \
d+
bytes to %s'
%
self
.
converted_notebook
)
self
.
assertTrue
(
os
.
path
.
exists
(
self
.
converted_notebook
))
with
open
(
self
.
converted_notebook
)
as
json_result
:
self
.
assertEqual
(
json
.
loads
(
json_result
.
read
())[
'cells'
][
0
][
'outputs'
][
0
][
'text'
][
0
],
self
.
test_sentence
+
'
\
n
'
,
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment