Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/tests/baseline_images/test_magic_plot/hist_null.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.
11 changes: 11 additions & 0 deletions src/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,14 @@ def tmp_empty(tmp_path):
os.chdir(str(tmp_path))
yield str(Path(tmp_path).resolve())
os.chdir(old)


@pytest.fixture
def load_penguin(ip):
tmp = "https://raw.githubusercontent.com/mwaskom/seaborn-data/master/penguins.csv"
if not Path("penguins.csv").is_file():
urllib.request.urlretrieve(
tmp,
"penguins.csv",
)
ip.run_cell("%sql duckdb://")
75 changes: 67 additions & 8 deletions src/tests/test_magic_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from sql import util

from matplotlib.testing.decorators import image_comparison, _cleanup_cm
import matplotlib

SUPPORTED_PLOTS = ["bar", "boxplot", "histogram", "pie"]
plot_str = util.pretty_print(SUPPORTED_PLOTS, last_delimiter="or")
Expand Down Expand Up @@ -278,13 +277,6 @@ def load_data_one_col_null(ip):
ip.run_cell("%sql duckdb://")


@_cleanup_cm()
@image_comparison(baseline_images=["hist_null"], extensions=["png"], remove_text=True)
def test_hist_one_col_null(load_data_one_col_null, ip):
out = ip.run_cell("%sqlplot histogram -t data_one_null.csv -c x --bins 2")
assert isinstance(out.result, matplotlib.axes._axes.Axes)


@_cleanup_cm()
@image_comparison(baseline_images=["bar_one_col"], extensions=["png"], remove_text=True)
def test_bar_one_col(load_data_one_col, ip):
Expand Down Expand Up @@ -357,6 +349,73 @@ def test_pie_two_col(load_data_two_col, ip):
ip.run_cell("%sqlplot pie -t data_two.csv -c x y")


@_cleanup_cm()
@image_comparison(baseline_images=["boxplot"], extensions=["png"], remove_text=True)
def test_boxplot(load_penguin, ip):
ip.run_cell("%sqlplot boxplot --table penguins.csv --column body_mass_g")


@_cleanup_cm()
@image_comparison(baseline_images=["boxplot_h"], extensions=["png"], remove_text=True)
def test_boxplot_h(load_penguin, ip):
ip.run_cell("%sqlplot boxplot --table penguins.csv --column body_mass_g --orient h")


@_cleanup_cm()
@image_comparison(baseline_images=["boxplot_two"], extensions=["png"], remove_text=True)
def test_boxplot_two_col(load_penguin, ip):
ip.run_cell(
"%sqlplot boxplot --table penguins.csv --column bill_length_mm "
"bill_depth_mm flipper_length_mm"
)


@_cleanup_cm()
@image_comparison(
baseline_images=["boxplot_null"], extensions=["png"], remove_text=True
)
def test_boxplot_null(load_penguin, ip):
ip.run_cell("%sqlplot boxplot --table penguins.csv --column bill_length_mm ")


@_cleanup_cm()
@image_comparison(baseline_images=["hist"], extensions=["png"], remove_text=True)
def test_hist(load_penguin, ip):
ip.run_cell("%sqlplot histogram --table penguins.csv --column body_mass_g")


@_cleanup_cm()
@image_comparison(baseline_images=["hist_bin"], extensions=["png"], remove_text=True)
def test_hist_bin(load_penguin, ip):
ip.run_cell(
"%sqlplot histogram --table penguins.csv --column body_mass_g --bins 300"
)


@_cleanup_cm()
@image_comparison(baseline_images=["hist_two"], extensions=["png"], remove_text=True)
def test_hist_two(load_penguin, ip):
ip.run_cell(
"%sqlplot histogram --table penguins.csv --column bill_length_mm bill_depth_mm"
)


@_cleanup_cm()
@image_comparison(baseline_images=["hist_null"], extensions=["png"], remove_text=True)
def test_hist_null(load_penguin, ip):
ip.run_cell("%sqlplot histogram --table penguins.csv --column bill_length_mm ")


@_cleanup_cm()
@image_comparison(baseline_images=["hist_custom"], extensions=["png"], remove_text=True)
def test_hist_cust(load_penguin, ip):
ax = ip.run_cell(
"%sqlplot histogram --table penguins.csv --column bill_length_mm "
).result
ax.set_title("Custom Title")
_ = ax.grid(True)


def test_sqlplot_deprecation_warning(ip_snippets, capsys):
with pytest.warns(FutureWarning) as record:
res = ip_snippets.run_cell(
Expand Down