예제 #1
0
 def setUp(self):
     with safexl.application(kill_after=False,
                             maximize=False,
                             include_addins=False) as prev_app:
         wb = prev_app.Workbooks.Add()
         self.assertEqual("Book1", wb.Name)
     self.assertTrue(safexl.is_excel_open())
예제 #2
0
 def test_no_error_alive_after(self):
     # No Error | Alive After - Excel in proc @ end
     with safexl.application(kill_after=False,
                             maximize=False,
                             include_addins=False) as app:
         wb = app.Workbooks.Add()
         ws = wb.ActiveSheet
         ws.Range("A1").Value = 555
         self.assertTrue(safexl.is_excel_open())
         self.assertEqual(wb.Name, "Book1")
         self.assertEqual(ws.Name, "Sheet1")
         self.assertEqual(ws.Range("A1").Value, 555)
     self.assertTrue(safexl.is_excel_open())
예제 #3
0
 def test_error_alive_after(self):
     # Error | Alive After - Excel not in proc @ end
     with self.assertRaises(safexl.toolkit.ExcelError):
         with safexl.application(kill_after=False,
                                 maximize=False,
                                 include_addins=False) as app:
             wb = app.Workbooks.Add()
             ws = wb.ActiveSheet
             self.assertTrue(safexl.is_excel_open())
             # Error on this line
             ws.Name = "a*b*c"
             # None of the following characters are allowed in sheet names
             # ["\\", "/", "*", "[", "]", ":", "?"]
     self.assertFalse(safexl.is_excel_open())
예제 #4
0
 def test_no_error_kill_after(self):
     # No Error | Kill After - prev Excel open after, new Excel gone
     current_openfile_count = len(safexl.toolkit.excel_open_files())
     with safexl.application(kill_after=True,
                             maximize=False,
                             include_addins=False) as app:
         wb = app.Workbooks.Add()
         ws = wb.ActiveSheet
         ws.Range("A1").Value = 555
         self.assertTrue(safexl.is_excel_open())
         self.assertEqual(len(safexl.toolkit.excel_open_files()),
                          current_openfile_count + 1)
         self.assertEqual(wb.Name, "Book2")
         self.assertEqual(ws.Name, "Sheet1")
         self.assertEqual(ws.Range("A1").Value, 555)
     self.assertEqual(len(safexl.toolkit.excel_open_files()),
                      current_openfile_count)
     self.assertTrue(safexl.is_excel_open())
예제 #5
0
 def test_error_alive_after(self):
     # Error | Alive After - prev Excel open after, new Excel gone
     with self.assertRaises(safexl.toolkit.ExcelError):
         current_openfile_count = len(safexl.toolkit.excel_open_files())
         with safexl.application(kill_after=False,
                                 maximize=False,
                                 include_addins=False) as app:
             wb = app.Workbooks.Add()
             ws = wb.ActiveSheet
             self.assertTrue(safexl.is_excel_open())
             self.assertEqual(len(safexl.toolkit.excel_open_files()),
                              current_openfile_count + 1)
             # Error on this line
             ws.Name = "a*b*c"
             # None of the following characters are allowed in sheet names
             # ["\\", "/", "*", "[", "]", ":", "?"]
     self.assertEqual(len(safexl.toolkit.excel_open_files()),
                      current_openfile_count)
     self.assertTrue(safexl.is_excel_open())