@pytest.mark.parametrize("dirname, tgt_folder, filename, expected", [pdf_tests[0]])
    def test_standalone_email(self, dirname, tgt_folder, filename, expected):
        # Run a single file conversion

        # Mock the smtplib to test the email functions
        with patch("smtplib.SMTP") as mock_smtp:
            cwd = os.getcwd()
            os.chdir(dirname)
            opts = [filename, "--preprocess", "--config=test_pypdfocr_config.yaml", "-m"]
            self.p.go(opts)

            out_filename = filename.replace(".pdf", "_ocr.pdf")
            assert(os.path.exists(out_filename))
            for i,t in enumerate(self._iter_pdf(out_filename)):
                if len(expected) > i:
                    for keyword in expected[i]:
                        assert(keyword in t)
                print ("\n----------------------\nPage %d\n" % i)
                print t
            os.remove(out_filename)
            os.chdir(cwd)
            
            # Assert the smtp calls
            instance = mock_smtp.return_value
            assert(instance.starttls.called)
            instance.login.assert_called_once_with("someone@gmail.com", "blah")
            assert(instance.sendmail.called)
Get coverage on the email after conversion of a single file.
dataset/ETHPy150Open virantha/pypdfocr/test/test_pypdfocr.py/TestPydfocr.test_standalone_email