Skip to content

Commit

Permalink
Adding scala test notebook for better testing support
Browse files Browse the repository at this point in the history
  • Loading branch information
Freshwood authored and mwouts committed Jun 13, 2019
1 parent 9840c50 commit 513b7a6
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 0 deletions.
75 changes: 75 additions & 0 deletions tests/notebooks/ipynb_scala/simple_scala_notebook.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"defined object SampleObject\n",
"result = 3\n"
]
},
"metadata": {},
"output_type": "display_data",
"source": "user"
},
{
"data": {
"text/plain": [
"3"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"// This is just a simple scala notebook\n",
"\n",
"object SampleObject {\n",
" def calculation(x: Int, y: Int): Int = x + y\n",
"}\n",
"\n",
"val result = SampleObject.calculation(1, 2)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"30\n"
]
}
],
"source": [
"println(result * 10)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Apache Toree - Scala",
"language": "scala",
"name": "apache_toree_scala"
},
"language_info": {
"codemirror_mode": "text/x-scala",
"file_extension": ".scala",
"mimetype": "text/x-scala",
"name": "scala",
"pygments_lexer": "scala",
"version": "2.11.12"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// ---
// jupyter:
// kernelspec:
// display_name: Apache Toree - Scala
// language: scala
// name: apache_toree_scala
// ---

// %%
// This is just a simple scala notebook

object SampleObject {
def calculation(x: Int, y: Int): Int = x + y
}

val result = SampleObject.calculation(1, 2)

// %%
println(result * 10)
19 changes: 19 additions & 0 deletions tests/notebooks/mirror/ipynb_to_script/simple_scala_notebook.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// ---
// jupyter:
// kernelspec:
// display_name: Apache Toree - Scala
// language: scala
// name: apache_toree_scala
// ---

// +
// This is just a simple scala notebook

object SampleObject {
def calculation(x: Int, y: Int): Int = x + y
}

val result = SampleObject.calculation(1, 2)
// -

println(result * 10)
12 changes: 12 additions & 0 deletions tests/test_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
"""

import os

import mock
import pytest
from nbformat.v4.nbbase import new_notebook
from testfixtures import compare

import jupytext
from jupytext.compare import compare_notebooks, combine_inputs_with_outputs
from jupytext.formats import long_form_one_format
Expand Down Expand Up @@ -315,3 +317,13 @@ def test_ipynb_to_ts(nb_file):
@pytest.mark.parametrize('nb_file', list_notebooks('ipynb_ts'))
def test_ipynb_to_ts_percent(nb_file):
assert_conversion_same_as_mirror(nb_file, 'ts:percent', 'ipynb_to_percent')


@pytest.mark.parametrize('nb_file', list_notebooks('ipynb_scala'))
def test_ipynb_to_scala(nb_file):
assert_conversion_same_as_mirror(nb_file, 'scala', 'ipynb_to_script')


@pytest.mark.parametrize('nb_file', list_notebooks('ipynb_scala'))
def test_ipynb_to_scala_percent(nb_file):
assert_conversion_same_as_mirror(nb_file, 'scala:percent', 'ipynb_to_percent')

0 comments on commit 513b7a6

Please sign in to comment.