-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: snapshot tests for diagrams (#239)
Closes #175. ### Summary of Changes Created tests to check if there are any graphic changes in the seaborn library by adding legacy graphics to compare to Co-authored-by: patrikguempel <128832338+patrikguempel@users.noreply.github.com> --------- Co-authored-by: megalinter-bot <129584137+megalinter-bot@users.noreply.github.com> Co-authored-by: Lars Reimann <mail@larsreimann.com>
- Loading branch information
1 parent
d47aaab
commit 4bc4c09
Showing
11 changed files
with
47 additions
and
47 deletions.
There are no files selected for viewing
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.
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.
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.
29 changes: 10 additions & 19 deletions
29
tests/safeds/data/tabular/containers/_column/test_plot_boxplot.py
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 |
---|---|---|
@@ -1,29 +1,20 @@ | ||
import _pytest | ||
import matplotlib.pyplot as plt | ||
import pytest | ||
from safeds.data.image.containers import Image | ||
from safeds.data.tabular.containers import Table | ||
from safeds.data.tabular.exceptions import NonNumericColumnError | ||
|
||
from tests.helpers import resolve_resource_path | ||
|
||
def test_plot_boxplot_complex() -> None: | ||
with pytest.raises(NotImplementedError): # noqa: PT012 | ||
table = Table.from_dict({"A": [1, 2, complex(1, -2)]}) | ||
table.get_column("A").plot_boxplot() | ||
|
||
def test_should_match_snapshot() -> None: | ||
table = Table.from_dict({"A": [1, 2, 3]}) | ||
table.get_column("A").plot_boxplot() | ||
current = table.get_column("A").plot_boxplot() | ||
snapshot = Image.from_png_file(resolve_resource_path("./image/snapshot_boxplot.png")) | ||
assert snapshot._image.tobytes() == current._image.tobytes() | ||
|
||
|
||
def test_plot_boxplot_non_numeric() -> None: | ||
def test_should_raise_if_column_contains_non_numerical_values() -> None: | ||
table = Table.from_dict({"A": [1, 2, "A"]}) | ||
with pytest.raises(NonNumericColumnError): | ||
table.get_column("A").plot_boxplot() | ||
|
||
|
||
def test_plot_boxplot_float(monkeypatch: _pytest.monkeypatch) -> None: | ||
monkeypatch.setattr(plt, "show", lambda: None) | ||
table = Table.from_dict({"A": [1, 2, 3.5]}) | ||
table.get_column("A").plot_boxplot() | ||
|
||
|
||
def test_plot_boxplot_int(monkeypatch: _pytest.monkeypatch) -> None: | ||
monkeypatch.setattr(plt, "show", lambda: None) | ||
table = Table.from_dict({"A": [1, 2, 3]}) | ||
table.get_column("A").plot_boxplot() |
19 changes: 14 additions & 5 deletions
19
tests/safeds/data/tabular/containers/_column/test_plot_histogram.py
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 |
---|---|---|
@@ -1,9 +1,18 @@ | ||
import _pytest | ||
import matplotlib.pyplot as plt | ||
from safeds.data.image.containers import Image | ||
from safeds.data.tabular.containers import Table | ||
|
||
from tests.helpers import resolve_resource_path | ||
|
||
def test_plot_histogram(monkeypatch: _pytest.monkeypatch) -> None: | ||
monkeypatch.setattr(plt, "show", lambda: None) | ||
|
||
def test_should_match_snapshot_numeric() -> None: | ||
table = Table.from_dict({"A": [1, 2, 3]}) | ||
table.get_column("A").plot_histogram() | ||
current = table.get_column("A").plot_histogram() | ||
snapshot = Image.from_png_file(resolve_resource_path("./image/snapshot_histogram_numeric.png")) | ||
assert snapshot._image.tobytes() == current._image.tobytes() | ||
|
||
|
||
def test_should_match_snapshot_str() -> None: | ||
table = Table.from_dict({"A": ["A", "B", "Apple"]}) | ||
current = table.get_column("A").plot_histogram() | ||
snapshot = Image.from_png_file(resolve_resource_path("./image/snapshot_histogram_str.png")) | ||
assert snapshot._image.tobytes() == current._image.tobytes() |
18 changes: 7 additions & 11 deletions
18
tests/safeds/data/tabular/containers/_table/test_plot_correlation_heatmap.py
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 |
---|---|---|
@@ -1,15 +1,11 @@ | ||
import _pytest | ||
import matplotlib.pyplot as plt | ||
from safeds.data.image.containers import Image | ||
from safeds.data.tabular.containers import Table | ||
|
||
from tests.helpers import resolve_resource_path | ||
|
||
def test_plot_correlation_heatmap_non_numeric(monkeypatch: _pytest.monkeypatch) -> None: | ||
monkeypatch.setattr(plt, "show", lambda: None) | ||
table = Table.from_dict({"A": [1, 2, "A"], "B": [1, 2, 3]}) | ||
table.plot_correlation_heatmap() | ||
|
||
|
||
def test_plot_correlation_heatmap(monkeypatch: _pytest.monkeypatch) -> None: | ||
monkeypatch.setattr(plt, "show", lambda: None) | ||
table = Table.from_dict({"A": [1, 2, 3.5], "B": [2, 4, 7]}) | ||
table.plot_correlation_heatmap() | ||
def test_should_match_snapshot() -> None: | ||
table = Table.from_dict({"A": [1, 2, 3.5], "B": [0.2, 4, 77]}) | ||
current = table.plot_correlation_heatmap() | ||
legacy = Image.from_png_file(resolve_resource_path("./image/snapshot_heatmap.png")) | ||
assert legacy._image.tobytes() == current._image.tobytes() |
14 changes: 8 additions & 6 deletions
14
tests/safeds/data/tabular/containers/_table/test_plot_lineplot.py
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 |
---|---|---|
@@ -1,17 +1,19 @@ | ||
import _pytest | ||
import matplotlib.pyplot as plt | ||
import pytest | ||
from safeds.data.image.containers import Image | ||
from safeds.data.tabular.containers import Table | ||
from safeds.data.tabular.exceptions import UnknownColumnNameError | ||
|
||
from tests.helpers import resolve_resource_path | ||
|
||
def test_plot_lineplot(monkeypatch: _pytest.monkeypatch) -> None: | ||
monkeypatch.setattr(plt, "show", lambda: None) | ||
|
||
def test_should_match_snapshot() -> None: | ||
table = Table.from_dict({"A": [1, 2, 3], "B": [2, 4, 7]}) | ||
table.plot_lineplot("A", "B") | ||
current = table.plot_lineplot("A", "B") | ||
snapshot = Image.from_png_file(resolve_resource_path("./image/snapshot_lineplot.png")) | ||
assert snapshot._image.tobytes() == current._image.tobytes() | ||
|
||
|
||
def test_plot_lineplot_wrong_column_name() -> None: | ||
def test_should_raise_if_column_does_not_exist() -> None: | ||
table = Table.from_dict({"A": [1, 2, 3], "B": [2, 4, 7]}) | ||
with pytest.raises(UnknownColumnNameError): | ||
table.plot_lineplot("C", "A") |
14 changes: 8 additions & 6 deletions
14
tests/safeds/data/tabular/containers/_table/test_plot_scatterplot.py
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 |
---|---|---|
@@ -1,17 +1,19 @@ | ||
import _pytest | ||
import matplotlib.pyplot as plt | ||
import pytest | ||
from safeds.data.image.containers import Image | ||
from safeds.data.tabular.containers import Table | ||
from safeds.data.tabular.exceptions import UnknownColumnNameError | ||
|
||
from tests.helpers import resolve_resource_path | ||
|
||
def test_plot_scatterplot(monkeypatch: _pytest.monkeypatch) -> None: | ||
monkeypatch.setattr(plt, "show", lambda: None) | ||
|
||
def test_should_match_snapshot() -> None: | ||
table = Table.from_dict({"A": [1, 2, 3], "B": [2, 4, 7]}) | ||
table.plot_scatterplot("A", "B") | ||
current = table.plot_scatterplot("A", "B") | ||
snapshot = Image.from_png_file(resolve_resource_path("./image/snapshot_scatterplot.png")) | ||
assert snapshot._image.tobytes() == current._image.tobytes() | ||
|
||
|
||
def test_plot_scatterplot_wrong_column_name() -> None: | ||
def test_should_raise_if_column_does_not_exist() -> None: | ||
table = Table.from_dict({"A": [1, 2, 3], "B": [2, 4, 7]}) | ||
with pytest.raises(UnknownColumnNameError): | ||
table.plot_scatterplot("C", "A") |