I want to write a unit test (using pytest) for a function which creates a plot of matplotlib but returns None.
Let's say the function show_plot would look like this:
import matplotlib.pyplot as plt
def show_plot():
    # create plot
    plt.plot([1, 2, 3], [4, 5, 3])
    # return None
    return None
When you call the function show_plot() you would see the created plot, but the plot object is not returned.
How can I write a unit test, to test that my function show_plot is plotting the correct plot? or at least checking that my function is indeed plotting something?
EDIT: I can't change or adjust my function show_plot()!
I need something like this:
def test_show_plot():
    # run show_plot
    show_plot()
    # Need help here!
    # ...
    # define plot_created
    # ...
    # logical value of plot_created, which indicates if a plot was
    # indeed created
    assert plot_created
For example I found here an interesting approach for stdout, and I hope there is something similar to capture plots.
 
     
    