-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from supunkamburugamuve/master
Initial structure for unit testing
- Loading branch information
Showing
6 changed files
with
61 additions
and
4 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
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,20 @@ | ||
#!/bin/bash | ||
|
||
python3 -m venv ENV | ||
|
||
source ENV/bin/activate | ||
|
||
pip install hublib | ||
pip install jupyterlab | ||
pip install testbook | ||
pip install widgetsnbextension | ||
pip install svgwrite | ||
pip install pypng | ||
pip install pytest | ||
pip install matplotlib | ||
pip install ipywidgets | ||
jupyter nbextension enable --py widgetsnbextension | ||
|
||
export ENVIRON_CONFIG_DIRS="," | ||
pytest test || exit 1 | ||
|
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,34 @@ | ||
import testbook | ||
import os | ||
import svgwrite | ||
import png | ||
|
||
@testbook.testbook('npshape-frontend.ipynb', execute=True) | ||
def test_combine_4_PNGs(tb): | ||
f = open('test/resources/test.png', 'wb') # binary mode is important | ||
w = png.Writer(256, 1, greyscale=True) | ||
w.write(f, [range(256)]) | ||
f.close() | ||
if not os.path.exists('snapshot_png'): | ||
os.mkdir("snapshot_png") | ||
|
||
func = tb.ref("combine_4_PNGs") | ||
func("test/resources/test.png", "test/resources/test.png", "test/resources/test.png", "test/resources/test.png", "test/resources/output.png") | ||
assert os.path.exists("test/resources/output.png") == 1 | ||
os.remove("test/resources/output.png") | ||
|
||
@testbook.testbook('npshape-frontend.ipynb', execute=True) | ||
def test_convert_SVG_PNG(tb): | ||
func = tb.ref("convert_SVG_PNG") | ||
|
||
dwg = svgwrite.Drawing('test/resources/test.svg', profile='tiny', size=(270, 270)) | ||
dwg.add(dwg.line((0, 0), (10, 0), stroke=svgwrite.rgb(10, 10, 16, '%'))) | ||
dwg.add(dwg.text('Test', insert=(0, 0.2), fill='red')) | ||
dwg.save() | ||
if not os.path.exists('snapshot_png'): | ||
os.mkdir("snapshot_png") | ||
|
||
func("test/resources/test.svg", "test/resources/output.png") | ||
assert os.path.exists("test/resources/output.png") == 1 | ||
os.remove("test/resources/output.png") | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.