'Testing Matplotlib Plot and Got error "not enough values to unpack (expected 2, got 0)"

I write and run a unit test for Matplotlib plot, but got the error "not enough values to unpack (expected 2, got 0)"

def plot(self):
        plt.style.use("seaborn")
    
        dates = list(self.summary.keys())
        incoming = list(item[1]["Incoming"] for item in self.summary.items())
        outgoing = list(item[1]["Outgoing"] for item in self.summary.items())
    
>       fig, ax = plt.subplots()
E       ValueError: not enough values to unpack (expected 2, got 0)

What does this error mean? and how to solve this?

This is my test code:

@mock.patch(f"{__name__}.summary.plt")
def test_incoming_mock_plot(self, mock_ax):
    reader = MBoxReader("file.mbox")
    ios = IncomingOutgoingSummary(reader=reader)
    ios.plot()
    print(mock_ax.set_title)
    mock_ax.set_ylabel.assert_called_once_with("Counts")
    mock_ax.set_title.assert_called_once_with(
        "Number of Incoming and Outgoing Emails per Month",
        fontdict={
            "fontname": "Helvetica",
            "color": "k",
            "fontweight": "bold",
            "fontsize": 12,
        },
    )
    assert mock_ax.figure.called


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source