diff --git a/features/steps/backend.py b/features/steps/backend.py index 32e1df52..da4ac633 100644 --- a/features/steps/backend.py +++ b/features/steps/backend.py @@ -6,11 +6,11 @@ import importlib import io -import nose.tools import numpy import os import xml.etree.ElementTree as xml +import test import testing if not os.path.exists(testing.backend_dir): @@ -30,7 +30,7 @@ def step_impl(context): target = os.path.join(testing.backend_dir, "%s.html" % context.name) context.backend.render(context.canvas, target) #html = xml.parse(target) - #nose.tools.assert_equal(html.getroot().tag, "{http://www.w3.org/2000/svg}svg") + #test.assert_equal(html.getroot().tag, "{http://www.w3.org/2000/svg}svg") @then(u'the canvas can be rendered to an html buffer') @@ -38,14 +38,14 @@ def step_impl(context): buffer = io.BytesIO() context.backend.render(context.canvas, buffer) #html = xml.parse(buffer.getvalue()) - #nose.tools.assert_equal(html.getroot().tag, "html") + #test.assert_equal(html.getroot().tag, "html") @then(u'the canvas can be rendered to a returned html dom') def step_impl(context): html = context.backend.render(context.canvas) - nose.tools.assert_is_instance(html, xml.Element) - nose.tools.assert_equal(html.tag, "div") + test.assert_is_instance(html, xml.Element) + test.assert_equal(html.tag, "div") @then(u'the canvas can be rendered to a pdf file') @@ -70,8 +70,8 @@ def step_impl(context): target = os.path.join(testing.backend_dir, "%s.png" % context.name) context.backend.render(context.canvas, target) image = testing.read_png(target) - nose.tools.assert_equal(image.shape, (600, 600, 4)) - nose.tools.assert_equal(image.dtype, "uint8") + test.assert_equal(image.shape, (600, 600, 4)) + test.assert_equal(image.dtype, "uint8") @then(u'the canvas can be rendered to a png buffer') @@ -81,38 +81,38 @@ def step_impl(context): buffer.seek(0) image = testing.read_png(buffer) - nose.tools.assert_equal(image.shape, (600, 600, 4)) - nose.tools.assert_equal(image.dtype, "uint8") + test.assert_equal(image.shape, (600, 600, 4)) + test.assert_equal(image.dtype, "uint8") @then(u'the canvas can be rendered to a returned png document') def step_impl(context): png = context.backend.render(context.canvas) image = testing.read_png(io.BytesIO(png)) - nose.tools.assert_equal(image.shape, (600, 600, 4)) - nose.tools.assert_equal(image.dtype, "uint8") + test.assert_equal(image.shape, (600, 600, 4)) + test.assert_equal(image.dtype, "uint8") @then(u'the canvas can be rendered to a 200 pixel wide png document') def step_impl(context): png = context.backend.render(context.canvas, width="200px") image = testing.read_png(io.BytesIO(png)) - nose.tools.assert_equal(image.shape, (200, 200, 4)) - nose.tools.assert_equal(image.dtype, "uint8") + test.assert_equal(image.shape, (200, 200, 4)) + test.assert_equal(image.dtype, "uint8") @then(u'the canvas can be rendered to a 150 pixel high png document') def step_impl(context): png = context.backend.render(context.canvas, height="150px") image = testing.read_png(io.BytesIO(png)) - nose.tools.assert_equal(image.shape, (150, 150, 4)) - nose.tools.assert_equal(image.dtype, "uint8") + test.assert_equal(image.shape, (150, 150, 4)) + test.assert_equal(image.dtype, "uint8") @then(u'the canvas can be rendered to a half scale png document') def step_impl(context): png = context.backend.render(context.canvas, scale=0.5) image = testing.read_png(io.BytesIO(png)) - nose.tools.assert_equal(image.shape, (300, 300, 4)) - nose.tools.assert_equal(image.dtype, "uint8") + test.assert_equal(image.shape, (300, 300, 4)) + test.assert_equal(image.dtype, "uint8") @then(u'the canvas can be rendered to an svg file') @@ -120,7 +120,7 @@ def step_impl(context): target = os.path.join(testing.backend_dir, "%s.svg" % context.name) context.backend.render(context.canvas, target) svg = xml.parse(target) - nose.tools.assert_equal(svg.getroot().tag, "{http://www.w3.org/2000/svg}svg") + test.assert_equal(svg.getroot().tag, "{http://www.w3.org/2000/svg}svg") @then(u'the canvas can be rendered to an svg buffer') @@ -128,11 +128,11 @@ def step_impl(context): buffer = io.BytesIO() context.backend.render(context.canvas, buffer) #svg = xml.parse(buffer.getvalue()) - #nose.tools.assert_equal(svg.getroot().tag, "svg") + #test.assert_equal(svg.getroot().tag, "svg") @then(u'the canvas can be rendered to a returned svg dom') def step_impl(context): svg = context.backend.render(context.canvas) - nose.tools.assert_is_instance(svg, xml.Element) - nose.tools.assert_equal(svg.tag, "svg") + test.assert_is_instance(svg, xml.Element) + test.assert_equal(svg.tag, "svg") diff --git a/features/steps/bar-visualization.py b/features/steps/bar-visualization.py index 78d93eaf..f183f078 100644 --- a/features/steps/bar-visualization.py +++ b/features/steps/bar-visualization.py @@ -6,7 +6,6 @@ import collections -import nose.tools import numpy.testing import toyplot diff --git a/features/steps/browser.py b/features/steps/browser.py index 54a580ca..239cf789 100644 --- a/features/steps/browser.py +++ b/features/steps/browser.py @@ -4,7 +4,7 @@ from behave import * -import nose.tools +import test import numpy import sys import toyplot.browser @@ -17,10 +17,10 @@ def step_impl(context): canvas, axes, mark = toyplot.plot(numpy.sin(numpy.linspace(0, 10))) with unittest.mock.patch("webbrowser.open") as webbrowser_open: toyplot.browser.show(canvas) - nose.tools.assert_equal(webbrowser_open.call_count, 1) - nose.tools.assert_true( + test.assert_equal(webbrowser_open.call_count, 1) + test.assert_true( webbrowser_open.call_args[0][0].startswith("file://")) - nose.tools.assert_equal(webbrowser_open.call_args[1]["new"], 1) - nose.tools.assert_equal(webbrowser_open.call_args[1]["autoraise"], True) + test.assert_equal(webbrowser_open.call_args[1]["new"], 1) + test.assert_equal(webbrowser_open.call_args[1]["autoraise"], True) diff --git a/features/steps/canvas.py b/features/steps/canvas.py index 3eff0016..e2215cf3 100644 --- a/features/steps/canvas.py +++ b/features/steps/canvas.py @@ -6,7 +6,7 @@ import io -import nose.tools +import test import numpy.testing import toyplot @@ -65,14 +65,14 @@ def step_impl(context): @then(u'the canvas can be rendered in Jupyter as HTML') def step_impl(context): html = context.canvas._repr_html_() - nose.tools.assert_is_instance(html, str) + test.assert_is_instance(html, str) @then(u'the canvas can be rendered in Jupyter as a PNG image') def step_impl(context): png = context.canvas._repr_png_() image = testing.read_png(io.BytesIO(png)) - nose.tools.assert_equal(image.shape, (600, 600, 4)) - nose.tools.assert_equal(image.dtype, "uint8") + test.assert_equal(image.shape, (600, 600, 4)) + test.assert_equal(image.dtype, "uint8") @then(u'numberlines can be added to the canvas using relative coordinates') def step_impl(context): diff --git a/features/steps/cartesian-coordinates.py b/features/steps/cartesian-coordinates.py index 635b0939..8c084069 100644 --- a/features/steps/cartesian-coordinates.py +++ b/features/steps/cartesian-coordinates.py @@ -4,7 +4,6 @@ from behave import * -import nose import numpy import toyplot.data @@ -19,58 +18,58 @@ def step_impl(context): @then(u'the cartesian axes can be rendered with hidden axes') def step_impl(context): context.axes.show = False - nose.tools.assert_equal(context.axes.show, False) + test.assert_equal(context.axes.show, False) @then(u'the cartesian axes can be rendered with axes label') def step_impl(context): context.axes.label.text = "Howdy!" - nose.tools.assert_equal(context.axes.label.text, "Howdy!") + test.assert_equal(context.axes.label.text, "Howdy!") context.axes.label.style = {"fill": "red"} - nose.tools.assert_equal(context.axes.label.style["fill"], "red") + test.assert_equal(context.axes.label.style["fill"], "red") @then(u'the cartesian axes can be rendered with hidden x axis') def step_impl(context): context.axes.x.show = False - nose.tools.assert_equal(context.axes.x.show, False) + test.assert_equal(context.axes.x.show, False) @then(u'the cartesian axes can be rendered with log-10 x scale') def step_impl(context): context.axes.x.scale = "log" - nose.tools.assert_equal(context.axes.x.scale, ("log", 10)) + test.assert_equal(context.axes.x.scale, ("log", 10)) @then(u'the cartesian axes can be rendered with hidden x spine') def step_impl(context): context.axes.x.spine.show = False - nose.tools.assert_equal(context.axes.x.spine.show, False) + test.assert_equal(context.axes.x.spine.show, False) @then( u'the cartesian axes can be rendered with x spine at an explicit position') def step_impl(context): context.axes.x.spine.position = 0 - nose.tools.assert_equal(context.axes.x.spine.position, 0) + test.assert_equal(context.axes.x.spine.position, 0) @then(u'the cartesian axes can be rendered with x spine at the high end of y') def step_impl(context): context.axes.x.spine.position = "high" - nose.tools.assert_equal(context.axes.x.spine.position, "high") + test.assert_equal(context.axes.x.spine.position, "high") @then(u'the cartesian axes can be rendered with styled x spine') def step_impl(context): context.axes.x.spine.style = {"stroke": "red"} - nose.tools.assert_equal(context.axes.x.spine.style["stroke"], "red") + test.assert_equal(context.axes.x.spine.style["stroke"], "red") @then(u'the cartesian axes can be rendered with visible x ticks') def step_impl(context): context.axes.x.ticks.show = True - nose.tools.assert_equal(context.axes.x.ticks.show, True) + test.assert_equal(context.axes.x.ticks.show, True) @then(u'the cartesian axes can be rendered with sized x ticks') @@ -78,15 +77,15 @@ def step_impl(context): context.axes.x.ticks.show = True context.axes.x.ticks.far = 10 context.axes.x.ticks.near = 3 - nose.tools.assert_equal(context.axes.x.ticks.far, 10) - nose.tools.assert_equal(context.axes.x.ticks.near, 3) + test.assert_equal(context.axes.x.ticks.far, 10) + test.assert_equal(context.axes.x.ticks.near, 3) @then(u'the cartesian axes can be rendered with styled x ticks') def step_impl(context): context.axes.x.ticks.show = True context.axes.x.ticks.style = {"stroke": "red"} - nose.tools.assert_equal(context.axes.x.ticks.style["stroke"], "red") + test.assert_equal(context.axes.x.ticks.style["stroke"], "red") @then( @@ -95,7 +94,7 @@ def step_impl(context): context.axes.x.ticks.show = True locator = toyplot.locator.Uniform(count=11) context.axes.x.ticks.locator = locator - nose.tools.assert_is(context.axes.x.ticks.locator, locator) + test.assert_is(context.axes.x.ticks.locator, locator) @then( @@ -103,7 +102,7 @@ def step_impl(context): def step_impl(context): context.axes.x.ticks.show = True context.axes.x.ticks.tick(index=0).style = {"stroke": "red"} - nose.tools.assert_equal( + test.assert_equal( context.axes.x.ticks.tick(index=0).style["stroke"], "red") @@ -112,40 +111,40 @@ def step_impl(context): def step_impl(context): context.axes.x.ticks.show = True context.axes.x.ticks.tick(value=0).style = {"stroke": "red"} - nose.tools.assert_equal( + test.assert_equal( context.axes.x.ticks.tick(value=0).style["stroke"], "red") @then(u'the cartesian axes can be rendered with hidden x tick labels') def step_impl(context): context.axes.x.ticks.labels.show = False - nose.tools.assert_equal(context.axes.x.ticks.labels.show, False) + test.assert_equal(context.axes.x.ticks.labels.show, False) @then(u'the cartesian axes can be rendered with angled x tick labels') def step_impl(context): context.axes.x.ticks.labels.angle = 45 - nose.tools.assert_equal(context.axes.x.ticks.labels.angle, 45) + test.assert_equal(context.axes.x.ticks.labels.angle, 45) context.axes.x.ticks.show = True @then(u'the cartesian axes can be rendered with offset x tick labels') def step_impl(context): context.axes.x.ticks.labels.offset = "0.125in" - nose.tools.assert_equal(context.axes.x.ticks.labels.offset, 12) + test.assert_equal(context.axes.x.ticks.labels.offset, 12) @then(u'the cartesian axes can be rendered with styled x tick labels') def step_impl(context): context.axes.x.ticks.labels.style = {"fill": "red"} - nose.tools.assert_equal(context.axes.x.ticks.labels.style["fill"], "red") + test.assert_equal(context.axes.x.ticks.labels.style["fill"], "red") @then( u'the cartesian axes can be rendered with x axis per-tick-label styles identified by index') def step_impl(context): context.axes.x.ticks.labels.label(index=0).style = {"fill": "red"} - nose.tools.assert_equal( + test.assert_equal( context.axes.x.ticks.labels.label(index=0).style["fill"], "red") @@ -153,67 +152,67 @@ def step_impl(context): u'the cartesian axes can be rendered with x axis per-tick-label styles identified by value') def step_impl(context): context.axes.x.ticks.labels.label(value=0).style = {"fill": "red"} - nose.tools.assert_equal( + test.assert_equal( context.axes.x.ticks.labels.label(value=0).style["fill"], "red") @then(u'the cartesian axes can be rendered with x axis label') def step_impl(context): context.axes.x.label.text = "Howdy!" - nose.tools.assert_equal(context.axes.x.label.text, "Howdy!") + test.assert_equal(context.axes.x.label.text, "Howdy!") context.axes.x.label.style = {"fill": "red"} - nose.tools.assert_equal(context.axes.x.label.style["fill"], "red") + test.assert_equal(context.axes.x.label.style["fill"], "red") @then(u'the cartesian axes can be rendered with explicit x axis domain') def step_impl(context): context.axes.x.domain.min = 0 - nose.tools.assert_equal(context.axes.x.domain.min, 0) + test.assert_equal(context.axes.x.domain.min, 0) context.axes.x.domain.max = 1 - nose.tools.assert_equal(context.axes.x.domain.max, 1) + test.assert_equal(context.axes.x.domain.max, 1) @then(u'the cartesian axes can be rendered with hidden y axis') def step_impl(context): context.axes.y.show = False - nose.tools.assert_equal(context.axes.y.show, False) + test.assert_equal(context.axes.y.show, False) @then(u'the cartesian axes can be rendered with log-10 y scale') def step_impl(context): context.axes.y.scale = "log" - nose.tools.assert_equal(context.axes.y.scale, ("log", 10)) + test.assert_equal(context.axes.y.scale, ("log", 10)) @then(u'the cartesian axes can be rendered with hidden y spine') def step_impl(context): context.axes.y.spine.show = False - nose.tools.assert_equal(context.axes.y.spine.show, False) + test.assert_equal(context.axes.y.spine.show, False) @then( u'the cartesian axes can be rendered with y spine at an explicit position') def step_impl(context): context.axes.y.spine.position = 10 - nose.tools.assert_equal(context.axes.y.spine.position, 10) + test.assert_equal(context.axes.y.spine.position, 10) @then(u'the cartesian axes can be rendered with y spine at the high end of x') def step_impl(context): context.axes.y.spine.position = "high" - nose.tools.assert_equal(context.axes.y.spine.position, "high") + test.assert_equal(context.axes.y.spine.position, "high") @then(u'the cartesian axes can be rendered with styled y spine') def step_impl(context): context.axes.y.spine.style = {"stroke": "red"} - nose.tools.assert_equal(context.axes.y.spine.style["stroke"], "red") + test.assert_equal(context.axes.y.spine.style["stroke"], "red") @then(u'the cartesian axes can be rendered with visible y ticks') def step_impl(context): context.axes.y.ticks.show = True - nose.tools.assert_equal(context.axes.y.ticks.show, True) + test.assert_equal(context.axes.y.ticks.show, True) @then(u'the cartesian axes can be rendered with sized y ticks') @@ -221,15 +220,15 @@ def step_impl(context): context.axes.y.ticks.show = True context.axes.y.ticks.near = 3 context.axes.y.ticks.far = 10 - nose.tools.assert_equal(context.axes.y.ticks.near, 3) - nose.tools.assert_equal(context.axes.y.ticks.far, 10) + test.assert_equal(context.axes.y.ticks.near, 3) + test.assert_equal(context.axes.y.ticks.far, 10) @then(u'the cartesian axes can be rendered with styled y ticks') def step_impl(context): context.axes.y.ticks.show = True context.axes.y.ticks.style = {"stroke": "red"} - nose.tools.assert_equal(context.axes.y.ticks.style["stroke"], "red") + test.assert_equal(context.axes.y.ticks.style["stroke"], "red") @then( @@ -238,7 +237,7 @@ def step_impl(context): context.axes.y.ticks.show = True locator = toyplot.locator.Uniform(count=5) context.axes.y.ticks.locator = locator - nose.tools.assert_is(context.axes.y.ticks.locator, locator) + test.assert_is(context.axes.y.ticks.locator, locator) @then( @@ -246,7 +245,7 @@ def step_impl(context): def step_impl(context): context.axes.y.ticks.show = True context.axes.y.ticks.tick(index=0).style = {"stroke": "red"} - nose.tools.assert_equal( + test.assert_equal( context.axes.y.ticks.tick(index=0).style["stroke"], "red") @@ -255,40 +254,40 @@ def step_impl(context): def step_impl(context): context.axes.y.ticks.show = True context.axes.y.ticks.tick(value=0).style = {"stroke": "red"} - nose.tools.assert_equal( + test.assert_equal( context.axes.y.ticks.tick(value=0).style["stroke"], "red") @then(u'the cartesian axes can be rendered with hidden y tick labels') def step_impl(context): context.axes.y.ticks.labels.show = False - nose.tools.assert_equal(context.axes.y.ticks.labels.show, False) + test.assert_equal(context.axes.y.ticks.labels.show, False) @then(u'the cartesian axes can be rendered with angled y tick labels') def step_impl(context): context.axes.y.ticks.labels.angle = -45 - nose.tools.assert_equal(context.axes.y.ticks.labels.angle, -45) + test.assert_equal(context.axes.y.ticks.labels.angle, -45) context.axes.y.ticks.show = True @then(u'the cartesian axes can be rendered with offset y tick labels') def step_impl(context): context.axes.y.ticks.labels.offset = "16px" - nose.tools.assert_equal(context.axes.y.ticks.labels.offset, 16) + test.assert_equal(context.axes.y.ticks.labels.offset, 16) @then(u'the cartesian axes can be rendered with styled y tick labels') def step_impl(context): context.axes.y.ticks.labels.style = {"fill": "red"} - nose.tools.assert_equal(context.axes.y.ticks.labels.style["fill"], "red") + test.assert_equal(context.axes.y.ticks.labels.style["fill"], "red") @then( u'the cartesian axes can be rendered with y axis per-tick-label styles identified by index') def step_impl(context): context.axes.y.ticks.labels.label(index=0).style = {"fill": "red"} - nose.tools.assert_equal( + test.assert_equal( context.axes.y.ticks.labels.label(index=0).style["fill"], "red") @@ -296,24 +295,24 @@ def step_impl(context): u'the cartesian axes can be rendered with y axis per-tick-label styles identified by value') def step_impl(context): context.axes.y.ticks.labels.label(value=0).style = {"fill": "red"} - nose.tools.assert_equal( + test.assert_equal( context.axes.y.ticks.labels.label(value=0).style["fill"], "red") @then(u'the cartesian axes can be rendered with y axis label') def step_impl(context): context.axes.y.label.text = "Howdy!" - nose.tools.assert_equal(context.axes.y.label.text, "Howdy!") + test.assert_equal(context.axes.y.label.text, "Howdy!") context.axes.y.label.style = {"fill": "red"} - nose.tools.assert_equal(context.axes.y.label.style["fill"], "red") + test.assert_equal(context.axes.y.label.style["fill"], "red") @then(u'the cartesian axes can be rendered with explicit y axis domain') def step_impl(context): context.axes.y.domain.min = 0 - nose.tools.assert_equal(context.axes.y.domain.min, 0) + test.assert_equal(context.axes.y.domain.min, 0) context.axes.y.domain.max = 1 - nose.tools.assert_equal(context.axes.y.domain.max, 1) + test.assert_equal(context.axes.y.domain.max, 1) @given(u'a shared axis') diff --git a/features/steps/color.py b/features/steps/color.py index 1c07a1e8..dd2f31be 100644 --- a/features/steps/color.py +++ b/features/steps/color.py @@ -6,7 +6,7 @@ from behave import * import json -import nose.tools +import test import numpy import toyplot.color @@ -31,7 +31,7 @@ def step_impl(context, value): @then(u'toyplot.color.to_css should return {value}') def step_impl(context, value): - nose.tools.assert_equal(toyplot.color.to_css(context.value), value) + test.assert_equal(toyplot.color.to_css(context.value), value) @given(u'a color value') @@ -59,7 +59,7 @@ def step_impl(context): @given(u'a color brewer category, the palette names for that category can be retrieved.') def step_impl(context): - nose.tools.assert_equal(toyplot.color.brewer.names("sequential"), [ + test.assert_equal(toyplot.color.brewer.names("sequential"), [ 'BlueGreen', 'BlueGreenYellow', 'BluePurple', @@ -79,7 +79,7 @@ def step_impl(context): 'RedPurple', 'Reds', ]) - nose.tools.assert_equal(toyplot.color.brewer.names("diverging"), [ + test.assert_equal(toyplot.color.brewer.names("diverging"), [ 'BlueGreenBrown', 'BlueRed', 'BlueYellowRed', @@ -90,7 +90,7 @@ def step_impl(context): 'PurpleOrange', 'Spectral', ]) - nose.tools.assert_equal(toyplot.color.brewer.names("qualitative"), [ + test.assert_equal(toyplot.color.brewer.names("qualitative"), [ 'Accent', 'Dark2', 'Paired', @@ -104,12 +104,12 @@ def step_impl(context): @given(u'a color brewer palette name, the color counts for that palette can be retrieved.') def step_impl(context): - nose.tools.assert_equal(toyplot.color.brewer.counts("BlueRed"), [3, 4, 5, 6, 7, 8, 9, 10, 11]) + test.assert_equal(toyplot.color.brewer.counts("BlueRed"), [3, 4, 5, 6, 7, 8, 9, 10, 11]) @given(u'a color brewer palette name, the category for that palette can be retrieved.') def step_impl(context): - nose.tools.assert_equal(toyplot.color.brewer.category("BlueRed"), "diverging") + test.assert_equal(toyplot.color.brewer.category("BlueRed"), "diverging") @when(u'the user creates a Color Brewer palette') @@ -202,15 +202,15 @@ def step_impl(context): @then( u'individual values can be mapped to css colors by the diverging color map') def step_impl(context): - nose.tools.assert_equal( + test.assert_equal( context.color_map.css(-1), "rgba(23.0%,29.9%,75.4%,1.000)") - nose.tools.assert_equal( + test.assert_equal( context.color_map.css(0), "rgba(23.0%,29.9%,75.4%,1.000)") - nose.tools.assert_equal( + test.assert_equal( context.color_map.css(0.5), "rgba(86.5%,86.5%,86.5%,1.000)") - nose.tools.assert_equal( + test.assert_equal( context.color_map.css(1), "rgba(70.6%,1.6%,15.0%,1.000)") - nose.tools.assert_equal( + test.assert_equal( context.color_map.css(2), "rgba(70.6%,1.6%,15.0%,1.000)") @@ -242,21 +242,21 @@ def step_impl(context): @then(u'the linear color map can map scalar values to css colors') def step_impl(context): - nose.tools.assert_equal(context.color_map.css(-1), "rgba(100.0%,0.0%,0.0%,1.000)") - nose.tools.assert_equal(context.color_map.css(0), "rgba(100.0%,0.0%,0.0%,1.000)") - nose.tools.assert_equal(context.color_map.css(0.5), "rgba(50.0%,0.0%,50.0%,1.000)") - nose.tools.assert_equal(context.color_map.css(1), "rgba(0.0%,0.0%,100.0%,1.000)") - nose.tools.assert_equal(context.color_map.css(2), "rgba(0.0%,0.0%,100.0%,1.000)") + test.assert_equal(context.color_map.css(-1), "rgba(100.0%,0.0%,0.0%,1.000)") + test.assert_equal(context.color_map.css(0), "rgba(100.0%,0.0%,0.0%,1.000)") + test.assert_equal(context.color_map.css(0.5), "rgba(50.0%,0.0%,50.0%,1.000)") + test.assert_equal(context.color_map.css(1), "rgba(0.0%,0.0%,100.0%,1.000)") + test.assert_equal(context.color_map.css(2), "rgba(0.0%,0.0%,100.0%,1.000)") @then(u'the color map domain can be changed') def step_impl(context): - nose.tools.assert_equal(context.color_map.domain.min, 0) - nose.tools.assert_equal(context.color_map.domain.max, 1) + test.assert_equal(context.color_map.domain.min, 0) + test.assert_equal(context.color_map.domain.max, 1) context.color_map.domain.min = -1 context.color_map.domain.max = 2 - nose.tools.assert_equal(context.color_map.domain.min, -1) - nose.tools.assert_equal(context.color_map.domain.max, 2) + test.assert_equal(context.color_map.domain.min, -1) + test.assert_equal(context.color_map.domain.max, 2) @given(u'a starting color') @@ -302,7 +302,7 @@ def step_impl(context): @then(u'the palette should contain 8 colors') def step_impl(context): - nose.tools.assert_equal(len(context.palette), 8) + test.assert_equal(len(context.palette), 8) @then(u'the default palette can be rendered as ipython html') @@ -351,9 +351,9 @@ def step_impl(context): testing.assert_color_equal(palette[0], (1, 0, 0, 1)) testing.assert_color_equal(palette[1], (0, 1, 0, 1)) testing.assert_color_equal(palette[-1], (0, 0, 1, 1)) - with nose.tools.assert_raises(IndexError): + with test.assert_raises(IndexError): palette[3] - with nose.tools.assert_raises(TypeError): + with test.assert_raises(TypeError): palette[0:3] @given(u'a color palette, callers can iterate over the colors') @@ -363,7 +363,7 @@ def step_impl(context): testing.assert_color_equal(next(color), (1, 0, 0, 1)) testing.assert_color_equal(next(color), (0, 1, 0, 1)) testing.assert_color_equal(next(color), (0, 0, 1, 1)) - with nose.tools.assert_raises(StopIteration): + with test.assert_raises(StopIteration): next(color) @given(u'a color palette, callers can retrieve colors by index') @@ -375,8 +375,8 @@ def step_impl(context): @given(u'a color palette, colors can retrieve css colors by index') def step_impl(context): palette = toyplot.color.Palette([(1, 0, 0), (0, 1, 0), (0, 0, 1)]) - nose.tools.assert_equal(palette.css(0), "rgba(100.0%,0.0%,0.0%,1.000)") - nose.tools.assert_equal(palette.css(-1), "rgba(0.0%,0.0%,100.0%,1.000)") + test.assert_equal(palette.css(0), "rgba(100.0%,0.0%,0.0%,1.000)") + test.assert_equal(palette.css(-1), "rgba(0.0%,0.0%,100.0%,1.000)") @given(u'a categorical color map, the map can be rendered as ipython html') def step_impl(context): @@ -402,6 +402,6 @@ def step_impl(context): def step_impl(context): colormap = toyplot.color.CategoricalMap( toyplot.color.Palette(["red", "lime", "blue", (1, 1, 1)])) - nose.tools.assert_equal(colormap.css(0), "rgba(100.0%,0.0%,0.0%,1.000)") - nose.tools.assert_equal(colormap.css(-1), "rgba(100.0%,100.0%,100.0%,1.000)") + test.assert_equal(colormap.css(0), "rgba(100.0%,0.0%,0.0%,1.000)") + test.assert_equal(colormap.css(-1), "rgba(100.0%,100.0%,100.0%,1.000)") diff --git a/features/steps/data-table.py b/features/steps/data-table.py index daa32e28..96f665ca 100644 --- a/features/steps/data-table.py +++ b/features/steps/data-table.py @@ -3,7 +3,7 @@ # rights in this software. from behave import * -import nose.tools +import test import numpy.testing import collections @@ -41,26 +41,26 @@ def step_impl(context): @then(u'the table should be empty') def step_impl(context): - nose.tools.assert_equal(len(context.data), 0) - nose.tools.assert_equal(context.data.shape, (0, 0)) - nose.tools.assert_equal(list(context.data.items()), []) - nose.tools.assert_equal(list(context.data.keys()), []) - nose.tools.assert_equal(list(context.data.values()), []) + test.assert_equal(len(context.data), 0) + test.assert_equal(context.data.shape, (0, 0)) + test.assert_equal(list(context.data.items()), []) + test.assert_equal(list(context.data.keys()), []) + test.assert_equal(list(context.data.values()), []) @then(u'adding columns should change the table') def step_impl(context): context.data["a"] = numpy.arange(10) - nose.tools.assert_equal(list(context.data.keys()), ["a"]) - nose.tools.assert_equal(context.data.shape, (10, 1)) + test.assert_equal(list(context.data.keys()), ["a"]) + test.assert_equal(context.data.shape, (10, 1)) context.data["b"] = context.data["a"] ** 2 - nose.tools.assert_equal(list(context.data.keys()), ["a", "b"]) - nose.tools.assert_equal(context.data.shape, (10, 2)) + test.assert_equal(list(context.data.keys()), ["a", "b"]) + test.assert_equal(context.data.shape, (10, 2)) context.data["c"] = numpy.zeros(10) - nose.tools.assert_equal(list(context.data.keys()), ["a", "b", "c"]) - nose.tools.assert_equal(context.data.shape, (10, 3)) + test.assert_equal(list(context.data.keys()), ["a", "b", "c"]) + test.assert_equal(context.data.shape, (10, 3)) @then(u'columns can be retrieved by name') @@ -70,7 +70,7 @@ def step_impl(context): @then(u'partial columns can be retrieved by name and index') def step_impl(context): - nose.tools.assert_equal(context.data["a", 5], 5) + test.assert_equal(context.data["a", 5], 5) @then(u'partial columns can be retrieved by name and slice') @@ -81,69 +81,69 @@ def step_impl(context): @then(u'partial tables can be retrieved by row index') def step_impl(context): table = context.data[5] - nose.tools.assert_equal(list(table.keys()), ["a", "b", "c"]) - nose.tools.assert_equal(table.shape, (1, 3)) + test.assert_equal(list(table.keys()), ["a", "b", "c"]) + test.assert_equal(table.shape, (1, 3)) numpy.testing.assert_array_equal(table["a"], [5]) @then(u'partial tables can be retrieved by row slice') def step_impl(context): table = context.data[5:7] - nose.tools.assert_equal(list(table.keys()), ["a", "b", "c"]) - nose.tools.assert_equal(table.shape, (2, 3)) + test.assert_equal(list(table.keys()), ["a", "b", "c"]) + test.assert_equal(table.shape, (2, 3)) numpy.testing.assert_array_equal(table["a"], [5,6]) @then(u'partial tables can be retrieved by row index and column name') def step_impl(context): table = context.data[5, "b"] - nose.tools.assert_equal(list(table.keys()), ["b"]) - nose.tools.assert_equal(table.shape, (1, 1)) + test.assert_equal(list(table.keys()), ["b"]) + test.assert_equal(table.shape, (1, 1)) numpy.testing.assert_array_equal(table["b"], [25]) @then(u'partial tables can be retrieved by row slice and column name') def step_impl(context): table = context.data[5:7, "b"] - nose.tools.assert_equal(list(table.keys()), ["b"]) - nose.tools.assert_equal(table.shape, (2, 1)) + test.assert_equal(list(table.keys()), ["b"]) + test.assert_equal(table.shape, (2, 1)) numpy.testing.assert_array_equal(table["b"], [25,36]) @then(u'partial tables can be retrieved by row index and column names') def step_impl(context): table = context.data[5, ["b", "a"]] - nose.tools.assert_equal(list(table.keys()), ["b", "a"]) - nose.tools.assert_equal(table.shape, (1, 2)) + test.assert_equal(list(table.keys()), ["b", "a"]) + test.assert_equal(table.shape, (1, 2)) numpy.testing.assert_array_equal(table["a"], [5]) @then(u'partial tables can be retrieved by row slice and column names') def step_impl(context): table = context.data[5:7, ["b", "a"]] - nose.tools.assert_equal(list(table.keys()), ["b", "a"]) - nose.tools.assert_equal(table.shape, (2, 2)) + test.assert_equal(list(table.keys()), ["b", "a"]) + test.assert_equal(table.shape, (2, 2)) numpy.testing.assert_array_equal(table["a"], [5,6]) @then(u'partial tables can be retrieved by column names') def step_impl(context): table = context.data[["b", "a"]] - nose.tools.assert_equal(list(table.keys()), ["b", "a"]) - nose.tools.assert_equal(table.shape, (10, 2)) + test.assert_equal(list(table.keys()), ["b", "a"]) + test.assert_equal(table.shape, (10, 2)) @then(u'partial tables can be retrieved by row indices') def step_impl(context): table = context.data[[5, 7]] - nose.tools.assert_equal(list(table.keys()), ["a", "b", "c"]) - nose.tools.assert_equal(table.shape, (2, 3)) + test.assert_equal(list(table.keys()), ["a", "b", "c"]) + test.assert_equal(table.shape, (2, 3)) numpy.testing.assert_array_equal(table["a"], [5, 7]) @then(u'columns can be replaced by name') def step_impl(context): context.data["c"] = numpy.ones(10) - nose.tools.assert_equal(list(context.data.keys()), ["a", "b", "c"]) - nose.tools.assert_equal(context.data.shape, (10, 3)) + test.assert_equal(list(context.data.keys()), ["a", "b", "c"]) + test.assert_equal(context.data.shape, (10, 3)) numpy.testing.assert_array_equal(context.data["c"], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) @@ -174,48 +174,48 @@ def step_impl(context): @then(u'partial columns can be masked by name and index') def step_impl(context): context.data["c", 3] = numpy.ma.masked - nose.tools.assert_is(context.data["c"][3], numpy.ma.masked) + test.assert_is(context.data["c"][3], numpy.ma.masked) @then(u'partial columns can be masked by name and slice') def step_impl(context): context.data["c", 8:10] = numpy.ma.masked - nose.tools.assert_is(context.data["c"][8], numpy.ma.masked) - nose.tools.assert_is(context.data["c"][9], numpy.ma.masked) + test.assert_is(context.data["c"][8], numpy.ma.masked) + test.assert_is(context.data["c"][9], numpy.ma.masked) @then(u'deleting columns should change the table') def step_impl(context): del context.data["c"] - nose.tools.assert_equal(list(context.data.keys()), ["a", "b"]) - nose.tools.assert_equal(context.data.shape, (10, 2)) + test.assert_equal(list(context.data.keys()), ["a", "b"]) + test.assert_equal(context.data.shape, (10, 2)) @then(u'new columns must have a string name') def step_impl(context): - with nose.tools.assert_raises(ValueError): + with test.assert_raises(ValueError): context.data[3] = numpy.arange(10) @then(u'new columns must have the same number of rows as existing columns') def step_impl(context): - with nose.tools.assert_raises(ValueError): + with test.assert_raises(ValueError): context.data["c"] = numpy.random.random(4) @then(u'new columns must be one-dimensional') def step_impl(context): - with nose.tools.assert_raises(ValueError): + with test.assert_raises(ValueError): context.data["c"] = numpy.random.random((10, 4)) @then(u'per-column metadata can be specified') def step_impl(context): - nose.tools.assert_equal(context.data.metadata("b"), {}) + test.assert_equal(context.data.metadata("b"), {}) context.data.metadata("b")["foo"] = True - nose.tools.assert_equal(context.data.metadata("b"), {"foo": True}) + test.assert_equal(context.data.metadata("b"), {"foo": True}) - with nose.tools.assert_raises(ValueError): + with test.assert_raises(ValueError): context.data.metadata("c") @@ -232,11 +232,11 @@ def step_impl(context): @then(u'the toyplot.data.Table is empty') def step_impl(context): - nose.tools.assert_equal(len(context.data), 0) - nose.tools.assert_equal(context.data.shape, (0, 0)) - nose.tools.assert_equal(list(context.data.items()), []) - nose.tools.assert_equal(list(context.data.keys()), []) - nose.tools.assert_equal(list(context.data.values()), []) + test.assert_equal(len(context.data), 0) + test.assert_equal(context.data.shape, (0, 0)) + test.assert_equal(list(context.data.items()), []) + test.assert_equal(list(context.data.keys()), []) + test.assert_equal(list(context.data.values()), []) @when(u'toyplot.data.Table is initialized with a toyplot.data.Table') @@ -257,7 +257,7 @@ def step_impl(context): @then(u'the toyplot.data.Table contains the columns') def step_impl(context): table = toyplot.data.Table(context.data) - nose.tools.assert_equal(list(table.keys()), ["a", "b"]) + test.assert_equal(list(table.keys()), ["a", "b"]) numpy.testing.assert_array_equal( table["a"], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) numpy.testing.assert_array_equal( @@ -272,7 +272,7 @@ def step_impl(context): @then(u'the toyplot.data.Table contains the columns, sorted by key') def step_impl(context): table = toyplot.data.Table(context.data) - nose.tools.assert_equal(list(table.keys()), ["a", "b"]) + test.assert_equal(list(table.keys()), ["a", "b"]) numpy.testing.assert_array_equal( table["a"], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) numpy.testing.assert_array_equal( @@ -289,7 +289,7 @@ def step_impl(context): @then(u'the toyplot.data.Table contains the matrix columns with generated keys') def step_impl(context): table = toyplot.data.Table(context.data) - nose.tools.assert_equal(list(table.keys()), ["0", "1", "2", "3"]) + test.assert_equal(list(table.keys()), ["0", "1", "2", "3"]) numpy.testing.assert_array_equal( table["0"], [0, 4, 8, 12]) numpy.testing.assert_array_equal( @@ -312,7 +312,7 @@ def step_impl(context): @then(u'the toyplot.data.Table raises ValueError') def step_impl(context): - with nose.tools.assert_raises(ValueError): + with test.assert_raises(ValueError): toyplot.data.Table(context.data) @@ -333,10 +333,10 @@ def step_impl(context): @then(u'the toyplot.data.Table contains the csv file columns') def step_impl(context): - nose.tools.assert_equal(context.data.shape, (362, 6)) - nose.tools.assert_equal(list(context.data.keys()), ['STATION', 'STATION_NAME', 'DATE', 'TMAX', 'TMIN', 'TOBS']) + test.assert_equal(context.data.shape, (362, 6)) + test.assert_equal(list(context.data.keys()), ['STATION', 'STATION_NAME', 'DATE', 'TMAX', 'TMIN', 'TOBS']) for column in context.data.values(): - nose.tools.assert_true(issubclass(column.dtype.type, numpy.character)) + test.assert_true(issubclass(column.dtype.type, numpy.character)) @when(u'toyplot.data.Table is initialized with a csv file and conversion') @@ -346,10 +346,10 @@ def step_impl(context): @then(u'the toyplot.data.Table contains the csv file columns with numeric type') def step_impl(context): - nose.tools.assert_equal(context.data.shape, (362, 6)) - nose.tools.assert_equal(list(context.data.keys()), ['STATION', 'STATION_NAME', 'DATE', 'TMAX', 'TMIN', 'TOBS']) + test.assert_equal(context.data.shape, (362, 6)) + test.assert_equal(list(context.data.keys()), ['STATION', 'STATION_NAME', 'DATE', 'TMAX', 'TMIN', 'TOBS']) for column, column_type in zip(context.data.values(), [numpy.character, numpy.character, numpy.integer, numpy.integer, numpy.integer, numpy.integer]): - nose.tools.assert_true(issubclass(column.dtype.type, column_type)) + test.assert_true(issubclass(column.dtype.type, column_type)) @when(u'toyplot.data.Table is initialized with a pandas dataframe') @@ -360,8 +360,8 @@ def step_impl(context): @then(u'the toyplot.data.Table contains the data frame columns') def step_impl(context): - nose.tools.assert_equal(context.data.shape, (362, 6)) - nose.tools.assert_equal(list(context.data.keys()), ['STATION', 'STATION_NAME', 'DATE', 'TMAX', 'TMIN', 'TOBS']) + test.assert_equal(context.data.shape, (362, 6)) + test.assert_equal(list(context.data.keys()), ['STATION', 'STATION_NAME', 'DATE', 'TMAX', 'TMIN', 'TOBS']) @when(u'toyplot.data.Table is initialized with a pandas dataframe with index') @@ -372,8 +372,8 @@ def step_impl(context): @then(u'the toyplot.data.Table contains the data frame columns plus an index column') def step_impl(context): - nose.tools.assert_equal(context.data.shape, (362, 7)) - nose.tools.assert_equal(list(context.data.keys()), ["index0", 'STATION', 'STATION_NAME', 'DATE', 'TMAX', 'TMIN', 'TOBS']) + test.assert_equal(context.data.shape, (362, 7)) + test.assert_equal(list(context.data.keys()), ["index0", 'STATION', 'STATION_NAME', 'DATE', 'TMAX', 'TMIN', 'TOBS']) @when(u'toyplot.data.Table is initialized with a pandas dataframe with hierarchical index') @@ -386,8 +386,8 @@ def step_impl(context): @then(u'the toyplot.data.Table contains the data frame columns plus multiple index columns') def step_impl(context): - nose.tools.assert_equal(context.data.shape, (4, 6)) - nose.tools.assert_equal(list(context.data.keys()), ["index0", 'index1', '0', '1', '2', '3']) + test.assert_equal(context.data.shape, (4, 6)) + test.assert_equal(list(context.data.keys()), ["index0", 'index1', '0', '1', '2', '3']) @when(u'toyplot.data.Table is initialized with a pandas dataframe with hierarchical index and custom index format') @@ -400,8 +400,8 @@ def step_impl(context): @then(u'the toyplot.data.Table contains the data frame columns plus multiple custom format index columns') def step_impl(context): - nose.tools.assert_equal(context.data.shape, (4, 6)) - nose.tools.assert_equal(list(context.data.keys()), ["Index 0", 'Index 1', '0', '1', '2', '3']) + test.assert_equal(context.data.shape, (4, 6)) + test.assert_equal(list(context.data.keys()), ["Index 0", 'Index 1', '0', '1', '2', '3']) @when(u'toyplot.data.Table is initialized with a pandas dataframe with duplicate column names') @@ -412,13 +412,13 @@ def step_impl(context): @then(u'the toyplot.data.Table contains the data frame columns with uniqified column names') def step_impl(context): - nose.tools.assert_equal(list(context.data.keys()), ['STATION', 'DATE', 'STATION-1', 'DATE-1', 'DATE-2']) + test.assert_equal(list(context.data.keys()), ['STATION', 'DATE', 'STATION-1', 'DATE-1', 'DATE-2']) @then(u'the table can be rendered as format ipython html string') def step_impl(context): html = context.data._repr_html_() - nose.tools.assert_is_instance(html, str) + test.assert_is_instance(html, str) testing.assert_html_equal(html, "data-table") diff --git a/features/steps/data.py b/features/steps/data.py index 0622753f..4d9900c9 100644 --- a/features/steps/data.py +++ b/features/steps/data.py @@ -3,7 +3,7 @@ # rights in this software. from behave import * -import nose.tools +import test import numpy.testing import toyplot.data diff --git a/features/steps/documentation.py b/features/steps/documentation.py index abb2007f..b14294fd 100644 --- a/features/steps/documentation.py +++ b/features/steps/documentation.py @@ -3,7 +3,7 @@ # rights in this software. from behave import * -import nose.tools +import test import glob import logging diff --git a/features/steps/fill-visualization.py b/features/steps/fill-visualization.py index 530c4604..a9ccfa3d 100644 --- a/features/steps/fill-visualization.py +++ b/features/steps/fill-visualization.py @@ -4,7 +4,6 @@ from behave import * -import nose import numpy import toyplot.data diff --git a/features/steps/format.py b/features/steps/format.py index 3e5b6f30..86a7de0c 100644 --- a/features/steps/format.py +++ b/features/steps/format.py @@ -4,7 +4,7 @@ from behave import * -import nose.tools +import test import numpy.testing import toyplot.format @@ -39,7 +39,7 @@ def step_impl(context, value, output): value = eval(value) output = eval(output) prefix, separator, suffix = context.formatter.format(value) - nose.tools.assert_equal(prefix, output[0]) - nose.tools.assert_equal(separator, output[1]) - nose.tools.assert_equal(suffix, output[2]) + test.assert_equal(prefix, output[0]) + test.assert_equal(separator, output[1]) + test.assert_equal(suffix, output[2]) diff --git a/features/steps/image-visualization.py b/features/steps/image-visualization.py index 1fedeb82..4270a9f0 100644 --- a/features/steps/image-visualization.py +++ b/features/steps/image-visualization.py @@ -6,7 +6,7 @@ import os -import nose.tools +import test import numpy import PIL.Image import toyplot.color @@ -21,89 +21,89 @@ def step_impl(context): context.image = testing.read_png(os.path.join(art_dir, "toyplot-8-L.png")) context.image = context.image > 128 - nose.tools.assert_equal(context.image.shape, (256, 256, 1)) - nose.tools.assert_equal(context.image.dtype, "bool") + test.assert_equal(context.image.shape, (256, 256, 1)) + test.assert_equal(context.image.dtype, "bool") @given(u'a numpy 8 bit L image') def step_impl(context): context.image = testing.read_png(os.path.join(art_dir, "toyplot-8-L.png")) - nose.tools.assert_equal(context.image.shape, (256, 256, 1)) - nose.tools.assert_equal(context.image.dtype, "uint8") + test.assert_equal(context.image.shape, (256, 256, 1)) + test.assert_equal(context.image.dtype, "uint8") @given(u'a numpy 8 bit L image with colormap') def step_impl(context): context.image = testing.read_png(os.path.join(art_dir, "toyplot-8-L.png")) - nose.tools.assert_equal(context.image.shape, (256, 256, 1)) - nose.tools.assert_equal(context.image.dtype, "uint8") + test.assert_equal(context.image.shape, (256, 256, 1)) + test.assert_equal(context.image.dtype, "uint8") context.image = (context.image, toyplot.color.brewer.map("BlueRed")) @given(u'a numpy 8 bit LA image') def step_impl(context): context.image = testing.read_png(os.path.join(art_dir, "toyplot-8-LA.png")) - nose.tools.assert_equal(context.image.shape, (256, 256, 2)) - nose.tools.assert_equal(context.image.dtype, "uint8") + test.assert_equal(context.image.shape, (256, 256, 2)) + test.assert_equal(context.image.dtype, "uint8") @given(u'a numpy 8 bit RGB image') def step_impl(context): context.image = testing.read_png(os.path.join(art_dir, "toyplot-8-RGB.png")) - nose.tools.assert_equal(context.image.shape, (256, 256, 3)) - nose.tools.assert_equal(context.image.dtype, "uint8") + test.assert_equal(context.image.shape, (256, 256, 3)) + test.assert_equal(context.image.dtype, "uint8") @given(u'a numpy 8 bit RGBA image') def step_impl(context): context.image = testing.read_png(os.path.join(art_dir, "toyplot-8-RGBA.png")) - nose.tools.assert_equal(context.image.shape, (256, 256, 4)) - nose.tools.assert_equal(context.image.dtype, "uint8") + test.assert_equal(context.image.shape, (256, 256, 4)) + test.assert_equal(context.image.dtype, "uint8") @given(u'a pillow 8 bit L image') def step_impl(context): context.image = PIL.Image.open(os.path.join(art_dir, "toyplot-8-L.png")) - nose.tools.assert_equal(context.image.size, (256, 256)) - nose.tools.assert_equal(context.image.mode, "L") + test.assert_equal(context.image.size, (256, 256)) + test.assert_equal(context.image.mode, "L") @given(u'a pillow 8 bit L image with colormap') def step_impl(context): context.image = PIL.Image.open(os.path.join(art_dir, "toyplot-8-L.png")) - nose.tools.assert_equal(context.image.size, (256, 256)) - nose.tools.assert_equal(context.image.mode, "L") + test.assert_equal(context.image.size, (256, 256)) + test.assert_equal(context.image.mode, "L") context.image = (context.image, toyplot.color.brewer.map("BlueRed")) @given(u'a pillow 8 bit RGB image') def step_impl(context): context.image = PIL.Image.open(os.path.join(art_dir, "toyplot-8-RGB.png")) - nose.tools.assert_equal(context.image.size, (256, 256)) - nose.tools.assert_equal(context.image.mode, "RGB") + test.assert_equal(context.image.size, (256, 256)) + test.assert_equal(context.image.mode, "RGB") @given(u'a pillow 8 bit RGBA image') def step_impl(context): context.image = PIL.Image.open(os.path.join(art_dir, "toyplot-8-RGBA.png")) - nose.tools.assert_equal(context.image.size, (256, 256)) - nose.tools.assert_equal(context.image.mode, "RGBA") + test.assert_equal(context.image.size, (256, 256)) + test.assert_equal(context.image.mode, "RGBA") @given(u'a non-square numpy 8 bit L image') def step_impl(context): numpy.random.seed(1234) context.image = numpy.random.uniform(0, 1, size=(10, 5)).repeat(50, axis=0).repeat(50, axis=1) - nose.tools.assert_equal(context.image.shape, (500, 250)) - nose.tools.assert_equal(context.image.dtype, "float64") + test.assert_equal(context.image.shape, (500, 250)) + test.assert_equal(context.image.dtype, "float64") @given(u'a non-square numpy 8 bit L image with colormap') def step_impl(context): numpy.random.seed(1234) context.image = numpy.random.uniform(0, 1, size=(10, 5)).repeat(50, axis=0).repeat(50, axis=1) - nose.tools.assert_equal(context.image.shape, (500, 250)) - nose.tools.assert_equal(context.image.dtype, "float64") + test.assert_equal(context.image.shape, (500, 250)) + test.assert_equal(context.image.dtype, "float64") context.image = (context.image, toyplot.color.linear.map("Blackbody")) diff --git a/features/steps/legends.py b/features/steps/legends.py index 12bba7c4..1583c4d7 100644 --- a/features/steps/legends.py +++ b/features/steps/legends.py @@ -3,7 +3,7 @@ # rights in this software. from behave import * -import nose.tools +import test import numpy def sample_data(): diff --git a/features/steps/log-scale-axes.py b/features/steps/log-scale-axes.py index 00a29c4f..8fb2460d 100644 --- a/features/steps/log-scale-axes.py +++ b/features/steps/log-scale-axes.py @@ -4,7 +4,6 @@ from behave import * -import nose import numpy import toyplot.data diff --git a/features/steps/plot-visualization.py b/features/steps/plot-visualization.py index 96d5f028..af486c19 100644 --- a/features/steps/plot-visualization.py +++ b/features/steps/plot-visualization.py @@ -6,7 +6,7 @@ import collections -import nose.tools +import test import numpy.testing import toyplot diff --git a/features/steps/projection.py b/features/steps/projection.py index 283d98a7..0da8eb4c 100644 --- a/features/steps/projection.py +++ b/features/steps/projection.py @@ -3,7 +3,7 @@ # rights in this software. from behave import * -import nose.tools +import test import numpy.testing import toyplot.projection @@ -16,20 +16,20 @@ def step_impl(context): @then(u'0 should project to 0') def step_impl(context): - nose.tools.assert_equal(context.projection(0), 0) - nose.tools.assert_equal(context.projection.inverse(0), 0) + test.assert_equal(context.projection(0), 0) + test.assert_equal(context.projection.inverse(0), 0) @then(u'0.5 should project to 50') def step_impl(context): - nose.tools.assert_equal(context.projection(0.5), 50) - nose.tools.assert_equal(context.projection.inverse(50), 0.5) + test.assert_equal(context.projection(0.5), 50) + test.assert_equal(context.projection.inverse(50), 0.5) @then(u'1 should project to 100') def step_impl(context): - nose.tools.assert_equal(context.projection(1.0), 100) - nose.tools.assert_equal(context.projection.inverse(100), 1.0) + test.assert_equal(context.projection(1.0), 100) + test.assert_equal(context.projection.inverse(100), 1.0) @given(u'A log10 projection with 1, 100 and 0, 100') @@ -39,20 +39,20 @@ def step_impl(context): @then(u'1 should project to 0') def step_impl(context): - nose.tools.assert_equal(context.projection(1), 0) - nose.tools.assert_equal(context.projection.inverse(0), 1) + test.assert_equal(context.projection(1), 0) + test.assert_equal(context.projection.inverse(0), 1) @then(u'10 should project to 50') def step_impl(context): - nose.tools.assert_equal(context.projection(10), 50) - nose.tools.assert_equal(context.projection.inverse(50), 10) + test.assert_equal(context.projection(10), 50) + test.assert_equal(context.projection.inverse(50), 10) @then(u'100 should project to 100') def step_impl(context): - nose.tools.assert_equal(context.projection(100), 100) - nose.tools.assert_equal(context.projection.inverse(100), 100) + test.assert_equal(context.projection(100), 100) + test.assert_equal(context.projection.inverse(100), 100) @given(u'A log10 projection with -100, 100 and 0, 100') @@ -62,11 +62,11 @@ def step_impl(context): @then(u'-100 should project to 0') def step_impl(context): - nose.tools.assert_equal(context.projection(-100), 0) - nose.tools.assert_equal(context.projection.inverse(0), -100) + test.assert_equal(context.projection(-100), 0) + test.assert_equal(context.projection.inverse(0), -100) @then(u'0 should project to 50') def step_impl(context): - nose.tools.assert_equal(context.projection(0), 50) - nose.tools.assert_equal(context.projection.inverse(50), 0) + test.assert_equal(context.projection(0), 50) + test.assert_equal(context.projection.inverse(50), 0) diff --git a/features/steps/rectangle-visualization.py b/features/steps/rectangle-visualization.py index 976d4bac..d9150f5c 100644 --- a/features/steps/rectangle-visualization.py +++ b/features/steps/rectangle-visualization.py @@ -6,7 +6,7 @@ import collections -import nose.tools +import test import numpy.testing import toyplot diff --git a/features/steps/scatterplot-visualization.py b/features/steps/scatterplot-visualization.py index 70d7664a..6a934fc3 100644 --- a/features/steps/scatterplot-visualization.py +++ b/features/steps/scatterplot-visualization.py @@ -6,7 +6,7 @@ import collections -import nose.tools +import test import numpy.testing import toyplot diff --git a/features/steps/table-visualization.py b/features/steps/table-visualization.py index 423b2b27..34d635c1 100644 --- a/features/steps/table-visualization.py +++ b/features/steps/table-visualization.py @@ -4,7 +4,6 @@ from behave import * -import nose import numpy import toyplot.data diff --git a/features/steps/test.py b/features/steps/test.py new file mode 100644 index 00000000..04a16ba8 --- /dev/null +++ b/features/steps/test.py @@ -0,0 +1,41 @@ +# Copyright 2014, Sandia Corporation. Under the terms of Contract +# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains certain +# rights in this software. + + +import unittest + +# Repackaging existing tests for PEP-8. + +def assert_almost_equal(first, second, places=7, delta=None, msg=None): + return unittest.TestCase().assertAlmostEqual(first, second, places=places, msg=msg, delta=delta) + +def assert_dict_equal(first, second, msg=None): + return unittest.TestCase().assertDictEqual(first, second, msg) + +def assert_equal(first, second, msg=None): + return unittest.TestCase().assertEqual(first, second, msg) + +def assert_false(expr, msg=None): + return unittest.TestCase().assertFalse(expr, msg) + +def assert_is(first, second, msg=None): + return unittest.TestCase().assertIs(first, second, msg) + +def assert_is_instance(obj, cls, msg=None): + return unittest.TestCase().assertIsInstance(obj, cls, msg) + +def assert_is_none(expr, msg=None): + return unittest.TestCase().assertIsNone(expr, msg) + +def assert_logs(logger=None, level=None): + return unittest.TestCase().assertLogs(logger, level) + +def assert_no_logs(logger=None, level=None): + return unittest.TestCase().assertNoLogs(logger, level) + +def assert_sequence_equal(first, second, msg=None, seq_type=None): + return unittest.TestCase().assertSequenceEqual(first, second, msg, seq_type) + +def assert_true(expr, msg=None): + return unittest.TestCase().assertTrue(expr, msg) diff --git a/features/steps/text.py b/features/steps/text.py index 16a45797..d81721a1 100644 --- a/features/steps/text.py +++ b/features/steps/text.py @@ -4,7 +4,7 @@ from behave import * -import nose.tools +import test import toyplot.html @@ -184,7 +184,7 @@ def step_impl(context): @when(u'text is aligned with an unknown text-anchor value, an exception is raised.') def step_impl(context): - with nose.tools.assert_raises(ValueError): + with test.assert_raises(ValueError): context.axes.text( 0, 0, "Text!", style={"text-anchor": "foo"}) toyplot.html.render(context.canvas) @@ -192,7 +192,7 @@ def step_impl(context): @when(u'text is aligned with an unknown alignment-baseline value, an exception is raised.') def step_impl(context): - with nose.tools.assert_raises(ValueError): + with test.assert_raises(ValueError): context.axes.text( 0, 0, "Text!", style={"alignment-baseline": "foo"}) toyplot.html.render(context.canvas) @@ -210,7 +210,7 @@ def step_impl(context, family): @when(u'text is drawn with an unknown font family, an exception is raised.') def step_impl(context): - with nose.tools.assert_raises(ValueError): + with test.assert_raises(ValueError): context.axes.text(0, 0, "Font-family: nonexistent", style={"font-family": "nonexistent", "font-size": "32px"}) context.canvas._repr_html_() diff --git a/features/steps/units.py b/features/steps/units.py index 2313b5e4..a2d9abae 100644 --- a/features/steps/units.py +++ b/features/steps/units.py @@ -3,7 +3,7 @@ # rights in this software. from behave import * -import nose.tools +import test import toyplot.units @@ -11,103 +11,103 @@ @when( u'converting "0" without default units to points the response should be 0.0') def step_impl(context): - nose.tools.assert_equal(toyplot.units.convert("0", "pt"), 0.0) + test.assert_equal(toyplot.units.convert("0", "pt"), 0.0) @when( u'converting 0 without default units to points the response should be 0.0') def step_impl(context): - nose.tools.assert_equal(toyplot.units.convert(0, "pt"), 0.0) + test.assert_equal(toyplot.units.convert(0, "pt"), 0.0) @when( u'converting 72 without default units to points the response should be raise ValueError') def step_impl(context): - with nose.tools.assert_raises(ValueError): + with test.assert_raises(ValueError): toyplot.units.convert(72, "pt") @when(u'converting 72 with default units pt to in the response should be 1.0') def step_impl(context): - nose.tools.assert_equal(toyplot.units.convert(72, "in", default="pt"), 1.0) + test.assert_equal(toyplot.units.convert(72, "in", default="pt"), 1.0) @when(u'converting "72pt" to in the response should be 1.0') def step_impl(context): - nose.tools.assert_equal(toyplot.units.convert("72pt", "in"), 1.0) + test.assert_equal(toyplot.units.convert("72pt", "in"), 1.0) @when(u'converting (72, "pt") to in the response should be 1.0') def step_impl(context): - nose.tools.assert_equal(toyplot.units.convert((72, "pt"), "in"), 1.0) + test.assert_equal(toyplot.units.convert((72, "pt"), "in"), 1.0) @when( u'converting "100%" without reference to in the response should be raise ValueError') def step_impl(context): - with nose.tools.assert_raises(ValueError): + with test.assert_raises(ValueError): toyplot.units.convert("100%", "in") @when(u'converting "100%" with reference 1.0 to in the response should be 1.0') def step_impl(context): - nose.tools.assert_equal( + test.assert_equal( toyplot.units.convert("100%", "in", reference=1.0), 1.0) @when(u'converting "40%" with reference 1.0 to in the response should be 0.4') def step_impl(context): - nose.tools.assert_equal( + test.assert_equal( toyplot.units.convert("40%", "in", reference=1.0), 0.4) @when(u'converting "96px" to in the response should be 1.0') def step_impl(context): - nose.tools.assert_equal(toyplot.units.convert("96px", "in"), 1.0) + test.assert_equal(toyplot.units.convert("96px", "in"), 1.0) @when(u'converting "96px" to pt the response should be 72.0') def step_impl(context): - nose.tools.assert_equal(toyplot.units.convert("96px", "pt"), 72.0) + test.assert_equal(toyplot.units.convert("96px", "pt"), 72.0) @when(u'converting ".5in" to pt the response should be 36.0') def step_impl(context): - nose.tools.assert_equal(toyplot.units.convert(".5in", "pt"), 36.0) + test.assert_equal(toyplot.units.convert(".5in", "pt"), 36.0) @when(u'converting "1in" to cm the response should be 2.54') def step_impl(context): - nose.tools.assert_almost_equal(toyplot.units.convert("1in", "cm"), 2.54) + test.assert_almost_equal(toyplot.units.convert("1in", "cm"), 2.54) @when(u'converting "1furlong" to in the response should be raise ValueError') def step_impl(context): - with nose.tools.assert_raises(ValueError): + with test.assert_raises(ValueError): toyplot.units.convert("1furlong", "in") @when(u'converting ("72pt",) to in the response should be raise ValueError') def step_impl(context): - with nose.tools.assert_raises(ValueError): + with test.assert_raises(ValueError): toyplot.units.convert(("72pt",), "in") @when(u'converting "1in" to furlong the response should be raise ValueError') def step_impl(context): - with nose.tools.assert_raises(ValueError): + with test.assert_raises(ValueError): toyplot.units.convert("1in", "furlong") @when(u'converting [] to in the response should be raise ValueError') def step_impl(context): - with nose.tools.assert_raises(ValueError): + with test.assert_raises(ValueError): toyplot.units.convert([], "in") @when(u'converting ("1","cm") to in the response should be raise ValueError') def step_impl(context): - with nose.tools.assert_raises(ValueError): + with test.assert_raises(ValueError): toyplot.units.convert(("1", "cm"), "in") @when(u'converting (1,2) to in the response should be raise ValueError') def step_impl(context): - with nose.tools.assert_raises(ValueError): + with test.assert_raises(ValueError): toyplot.units.convert((1, 2), "in") diff --git a/pyproject.toml b/pyproject.toml index 4a70f29d..e7a90065 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,6 @@ all = [ "coverage", "ipykernel", "nbsphinx", - "nose", "pandas", "scikit-image", "sphinx >= 3.5",