예제 #1
0
    def test_pdf(self):

        with named_file("", suffix=".pdf") as fname:
            imgio.MatplotlibPDFFormat.write(fname, self.plt.plotItem)
            with open(fname, "rb") as f:
                code = f.read()
            self.assertTrue(code.startswith(b"%PDF"))
예제 #2
0
 def test_python(self):
     with named_file("", suffix=".py") as fname:
         imgio.MatplotlibFormat.write(fname, self.plt.plotItem)
         with open(fname, "rt") as f:
             code = f.read()
         self.assertIn("plt.show()", code)
         self.assertIn("plt.scatter", code)
         # test if the runs
         exec(code.replace("plt.show()", ""), {})
예제 #3
0
    def test_write_defaults_handles_permission_error(self):
        handler = SettingsHandler()

        with named_file("") as f:
            handler._get_settings_filename = lambda: f

            with patch("orangewidget.settings.log.error") as log, \
                patch('orangewidget.settings.open', create=True,
                       side_effect=PermissionError):
                handler.write_defaults()
                log.assert_called()