-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first jupyter notebook tutorial with attempt at smooth unittest integ…
…ration
- Loading branch information
1 parent
f5a52fa
commit 8587bc0
Showing
5 changed files
with
1,406 additions
and
1 deletion.
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
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,31 @@ | ||
import nbformat | ||
import unittest | ||
import subprocess | ||
|
||
|
||
class TestTutorials(unittest.TestCase): | ||
def setUp(self): | ||
self.networktypes = "../tutorials/01_networktypes" | ||
|
||
def test_networktypes(self): | ||
res = subprocess.call( | ||
f"jupyter nbconvert --to notebook --execute {self.networktypes}.ipynb", | ||
shell=True, | ||
) | ||
nb = nbformat.read(f"{self.networktypes}.nbconvert.ipynb", as_version=4) | ||
nb_original = nbformat.read(f"{self.networktypes}.ipynb", as_version=4) | ||
out = [c["outputs"] for c in nb.cells if c["cell_type"] == "code"] | ||
out_original = [ | ||
c["outputs"] for c in nb_original.cells if c["cell_type"] == "code" | ||
] | ||
self.assertListEqual(out, out_original) | ||
|
||
def tearDown(self): | ||
subprocess.call( | ||
f"rm ../tutorials/{self.networktypes}.nbconvert.ipynb", shell=True | ||
) | ||
|
||
|
||
def test_tutorials(): | ||
suite = unittest.TestSuite() | ||
suite.addTest(TestTutorials("test_networktypes")) |
Oops, something went wrong.