def test_start(self,d):
        f = ErrorFilter()
        f.next = m = Mock()
        f.wtbook = 'junk'
        f.handler.fired = 'junk'
        f.temp_path = d.path
        f.prefix = 'junk'
        j = open(os.path.join(d.path,'junk.xls'),'wb')
        j.write('junk')
        j.close()

        f.start()

        compare(f.wtbook,None)
        compare(f.handler.fired,False)
        self.failIf(os.path.exists(d.path))
        compare(os.listdir(f.temp_path),[])
        compare(f.prefix,0)

        f.finish()
        
        compare(m.method_calls,[
            ('start', (), {}),
            ('finish', (), {})
            ])
 def test_multiple_workbooks_with_same_name(self,h):
     r = TestReader(
         ('Sheet1',[['S1R0C0']]),
         )
     book = tuple(r.get_workbooks())[0][0]
     # fire methods on filter
     f = ErrorFilter()
     f.next = c = Mock()
     f.start()
     f.workbook(book,'new.xls')
     f.sheet(book.sheet_by_index(0),'new1')
     f.cell(0,0,0,0)
     f.workbook(book,'new.xls')
     f.sheet(book.sheet_by_index(0),'new2')
     f.cell(0,0,0,0)
     f.finish()
     compare(c.method_calls,[
         ('start', (), {}),
         ('workbook', (C('xlrd.Book'), 'new.xls'),{}),
         ('sheet', (C('xlrd.sheet.Sheet',name='new1',strict=False), u'new1'),{}),
         ('row', (0, 0),{}),
         ('cell', (0, 0, 0, 0),{}),
         ('workbook', (C('xlrd.Book'), 'new.xls'),{}),
         ('sheet', (C('xlrd.sheet.Sheet',name='new2',strict=False), u'new2'),{}),
         ('row', (0, 0),{}),
         ('cell', (0, 0, 0, 0),{}),
         ('finish', (), {})
         ])
     self.assertEqual(len(h.records),0)
 def test_finish_resets(self):
     # ...that's `start`s job!
     r = TestReader(
         ('Sheet1',[[(XL_CELL_ERROR,0)]]),
         )
     book = tuple(r.get_workbooks())[0][0]
     # fire methods on filter
     f = ErrorFilter()
     f.next = c = Mock()
     f.start()
     f.workbook(book,'new.xls')
     f.sheet(book.sheet_by_index(0),'new1')
     f.cell(0,0,0,0)
     self.assertTrue(f.handler.fired)
     f.finish()
     compare(c.method_calls,[])
     self.assertFalse(f.handler.fired)
     compare(f.temp_path,None)
 def test_set_rdsheet_1(self,h):
     r = TestReader(
         ('Sheet1',[['S1R0C0']]),
         ('Sheet2',[[(XL_CELL_ERROR,0)]]),
         )
     book = tuple(r.get_workbooks())[0][0]
     # fire methods on filter
     f = ErrorFilter()
     f.next = c = Mock()
     f.start()
     f.workbook(book,'new.xls')
     f.sheet(book.sheet_by_index(0),'new')
     f.cell(0,0,0,0)
     f.set_rdsheet(book.sheet_by_index(1))
     f.cell(0,0,1,0)
     f.finish()
     compare(c.method_calls,[])
     h.check(
         ('xlutils.filter','ERROR',"Cell A1 of sheet 'Sheet2' contains a bad value: error (#NULL!)"),
         ('xlutils.filter','ERROR','No output as errors have occurred.'),
         )