title: Mocking method pandas.read_excel does not work with @patch
body: <p>I'm writing unit tests with Python for a project and recently encountered a problem with the decorator @patch. I have the following method which I need to test</p>
  <pre><code>def _read_from_disk(self, excel_kwargs):
          &quot;&quot;&quot;
          Read excel file from disk and apply excel_kwargs.
  
          Args:
              excel_kwargs: Parameters for pandas.read_excel.
  
          Returns:
              DataFrame or dict of DataFrames.
          &quot;&quot;&quot;
          return pd.read_excel(self.location, **excel_kwargs)
  </code></pre>
  <p>My test method structure is</p>
  <pre><code> @patch(&quot;program.data.excel.BaseExcelReader._read_from_disk.pd.read_excel&quot;)
      def test___read_from_disk(self, mock_df):
          mock_df.return_value = pd.DataFrame({&quot;test_id&quot;: [1, 2, 3, 4, 5]})
          return_df = self.test_reader._read_from_disk(self.excel_kwargs_svd)
          pd.testing.assert_frame_equal(return_df, pd.DataFrame({&quot;test_id&quot;: [1, 2, 3, 4, 5]}))
  </code></pre>
  <p>Which give me the following error:</p>
  <pre><code>ModuleNotFoundError: No module named 'program.data.excel.BaseExcelReader';
                         'program.data.excel' is not a package
  </code></pre>
  <p>Please note that the test method is only an example. The purpose of the question is to find a way to mock <code>pandas.read_excel</code> with @patch.</p>