Skip to content

Commit

Permalink
test: rename test methods
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-reimann committed May 5, 2023
1 parent 96af850 commit 640a4b9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 30 deletions.
18 changes: 6 additions & 12 deletions tests/safeds/data/tabular/containers/_column/test_plot_boxplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,15 @@
from tests.helpers import resolve_resource_path


def test_should_raise_NotImplementedError() -> 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_raise_NonNumericError() -> None:
table = Table.from_dict({"A": [1, 2, "A"]})
with pytest.raises(NonNumericColumnError):
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_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()
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
from tests.helpers import resolve_resource_path


def test_should_match_snapshot_str() -> None:
table = Table.from_dict({"A": ["A", "B", "Apple"]})
def test_should_match_snapshot_numeric() -> None:
table = Table.from_dict({"A": [1, 2, 3]})
current = table.get_column("A").plot_histogram()
snapshot = Image.from_png_file(resolve_resource_path("./image/snapshot_histogram_str.png"))
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_numeric() -> None:
table = Table.from_dict({"A": [1, 2, 3]})
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_numeric.png"))
snapshot = Image.from_png_file(resolve_resource_path("./image/snapshot_histogram_str.png"))
assert snapshot._image.tobytes() == current._image.tobytes()
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
from tests.helpers import resolve_resource_path


def test_should_raise_UnknownColumnNameError() -> None:
table = Table.from_dict({"A": [1, 2, 3], "B": [2, 4, 7]})
with pytest.raises(UnknownColumnNameError):
table.plot_lineplot("C", "A")


def test_should_match_snapshot() -> None:
table = Table.from_dict({"A": [1, 2, 3], "B": [2, 4, 7]})
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_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")
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
from tests.helpers import resolve_resource_path


def test_should_raise_UnknownColumnNameError() -> None:
table = Table.from_dict({"A": [1, 2, 3], "B": [2, 4, 7]})
with pytest.raises(UnknownColumnNameError):
table.plot_scatterplot("C", "A")


def test_should_match_snapshot() -> None:
table = Table.from_dict({"A": [1, 2, 3], "B": [2, 4, 7]})
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_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")

0 comments on commit 640a4b9

Please sign in to comment.