From 8edb4a2d18198b4016f7e446dba82b475378f002 Mon Sep 17 00:00:00 2001 From: Ollie-Gullery <2olivergullery@gmail.com> Date: Thu, 11 Apr 2024 17:37:25 -0700 Subject: [PATCH] Added docstrings to plotting tests --- tests/test_plotting.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/test_plotting.py b/tests/test_plotting.py index 069c75a..11ecfe7 100644 --- a/tests/test_plotting.py +++ b/tests/test_plotting.py @@ -11,25 +11,40 @@ # Check to see if output type is correct given correct inputs def test_sns_plotting_output_type(): + """_summary_ + Ensures that the output of the sns plotting function is a matplotlib figure + """ result = sns_plotting('scatterplot', data, 'number_of_reviews', 'price', 20, 10) assert type(result) == matplotlib.figure.Figure, "Test failed: Output type is incorrect." # Check to see if exception raised for n/a plot type def test_sns_plotting_plottype_error(): + """_summary_ + Ensures that running the sns plotting function with the incorrect inputs leads to an error + """ with pytest.raises(Exception): result = sns_plotting('barplot', data, 'number_of_reviews', 'price', 20, 10) # Check to see if value error raised for x-variable not in data def test_sns_plotting_x_error(): + """_summary_ + Ensures that running the sns plotting function with the incorrect inputs leads to an error + """ with pytest.raises(ValueError): sns_plotting('scatterplot', data, 'random_x', 'price', 20, 10) # Check to see if value error raised for y-variable not in data def test_sns_plotting_y_error(): + """_summary_ + Ensures that running the sns plotting function with the incorrect inputs leads to an error + """ with pytest.raises(ValueError): sns_plotting('scatterplot', data, 'number_of_reviews', 'random_y', 20, 10) # Check to see the figlength and figheight are both <= 25 to avoid being too large def test_sns_plotting_figsize_check(): + """_summary_ + Ensures that the figure size of the sns plot is of a reasonable size (<= 25 inches) + """ result = sns_plotting('scatterplot', data, 'number_of_reviews', 'price') assert result.get_size_inches()[0] <= 25 and result.get_size_inches()[1] <= 25, "Test failed: Plot size is too large." \ No newline at end of file