Exemple #1
0
class TestWorkbook:
    def setUp(self):
        # Connect to test file and make Sheet1 the active sheet
        xl_file1 = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'test_workbook_1.xlsx')
        self.wb = Workbook(xl_file1)
        Sheet('Sheet1').activate()

    def tearDown(self):
        self.wb.close()

    def test_name(self):
        assert_equal(self.wb.name, 'test_workbook_1.xlsx')

    def test_active_sheet(self):
        assert_equal(self.wb.active_sheet.name, 'Sheet1')

    def test_current(self):
        assert_equal(self.wb.xl_workbook, Workbook.current().xl_workbook)

    def test_set_current(self):
        wb2 = Workbook()
        assert_equal(Workbook.current().xl_workbook, wb2.xl_workbook)
        self.wb.set_current()
        assert_equal(Workbook.current().xl_workbook, self.wb.xl_workbook)
        wb2.close()

    def test_get_selection(self):
        Range('A1').value = 1000
        assert_equal(self.wb.get_selection().value, 1000)

    def test_reference_two_unsaved_wb(self):
        """Covers GH Issue #63"""
        wb1 = Workbook()
        wb2 = Workbook()

        Range('A1').value = 2.  # wb2
        Range('A1', wkb=wb1).value = 1.  # wb1

        assert_equal(Range('A1').value, 2.)
        assert_equal(Range('A1', wkb=wb1).value, 1.)

        wb1.close()
        wb2.close()
Exemple #2
0
class TestWorkbook:
    def setUp(self):
        # Connect to test file and make Sheet1 the active sheet
        xl_file1 = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                'test_workbook_1.xlsx')
        self.wb = Workbook(xl_file1, app_visible=False, app_target=APP_TARGET)
        Sheet('Sheet1').activate()

    def tearDown(self):
        self.wb.close()

    def test_name(self):
        assert_equal(self.wb.name, 'test_workbook_1.xlsx')

    def test_active_sheet(self):
        assert_equal(self.wb.active_sheet.name, 'Sheet1')

    def test_current(self):
        assert_equal(self.wb.xl_workbook, Workbook.current().xl_workbook)

    def test_set_current(self):
        wb2 = Workbook(app_visible=False, app_target=APP_TARGET)
        assert_equal(Workbook.current().xl_workbook, wb2.xl_workbook)
        self.wb.set_current()
        assert_equal(Workbook.current().xl_workbook, self.wb.xl_workbook)
        wb2.close()

    def test_get_selection(self):
        Range('A1').value = 1000
        assert_equal(self.wb.get_selection().value, 1000)

    def test_reference_two_unsaved_wb(self):
        """Covers GH Issue #63"""
        wb1 = Workbook(app_visible=False, app_target=APP_TARGET)
        wb2 = Workbook(app_visible=False, app_target=APP_TARGET)

        Range('A1').value = 2.  # wb2
        Range('A1', wkb=wb1).value = 1.  # wb1

        assert_equal(Range('A1').value, 2.)
        assert_equal(Range('A1', wkb=wb1).value, 1.)

        wb1.close()
        wb2.close()

    def test_save_naked(self):

        cwd = os.getcwd()
        wb1 = Workbook(app_visible=False, app_target=APP_TARGET)
        target_file_path = os.path.join(cwd, wb1.name + '.xlsx')
        if os.path.isfile(target_file_path):
            os.remove(target_file_path)

        wb1.save()

        assert_equal(os.path.isfile(target_file_path), True)

        wb2 = Workbook(target_file_path,
                       app_visible=False,
                       app_target=APP_TARGET)
        wb2.close()

        if os.path.isfile(target_file_path):
            os.remove(target_file_path)

    def test_save_path(self):

        cwd = os.getcwd()
        wb1 = Workbook(app_visible=False, app_target=APP_TARGET)
        target_file_path = os.path.join(cwd, 'TestFile.xlsx')
        if os.path.isfile(target_file_path):
            os.remove(target_file_path)

        wb1.save(target_file_path)

        assert_equal(os.path.isfile(target_file_path), True)

        wb2 = Workbook(target_file_path,
                       app_visible=False,
                       app_target=APP_TARGET)
        wb2.close()

        if os.path.isfile(target_file_path):
            os.remove(target_file_path)

    def test_mock_caller(self):
        _skip_if_not_default_xl()

        Workbook.set_mock_caller(
            os.path.join(os.path.dirname(os.path.abspath(__file__)),
                         'test_workbook_1.xlsx'))
        wb = Workbook.caller()
        Range('A1', wkb=wb).value = 333
        assert_equal(Range('A1', wkb=wb).value, 333)

    def test_unicode_path(self):
        # pip3 seems to struggle with unicode filenames
        src = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                           'unicode_path.xlsx')
        dst = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                           'ünicödé_päth.xlsx')
        shutil.move(src, dst)
        wb = Workbook(os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                   'ünicödé_päth.xlsx'),
                      app_target=APP_TARGET)
        Range('A1').value = 1
        wb.close()
        shutil.move(dst, src)

    def unsaved_workbook_reference(self):
        wb = Workbook(app_visible=False, app_target=APP_TARGET)
        Range('B2').value = 123
        wb2 = Workbook(wb.name, app_visible=False, app_target=APP_TARGET)
        assert_equal(Range('B2', wkb=wb2).value, 123)
Exemple #3
0
class TestWorkbook:
    def setUp(self):
        # Connect to test file and make Sheet1 the active sheet
        xl_file1 = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                'test_workbook_1.xlsx')
        self.wb = Workbook(xl_file1)
        Sheet('Sheet1').activate()

    def tearDown(self):
        self.wb.close()

    def test_name(self):
        assert_equal(self.wb.name, 'test_workbook_1.xlsx')

    def test_active_sheet(self):
        assert_equal(self.wb.active_sheet.name, 'Sheet1')

    def test_current(self):
        assert_equal(self.wb.xl_workbook, Workbook.current().xl_workbook)

    def test_set_current(self):
        wb2 = Workbook()
        assert_equal(Workbook.current().xl_workbook, wb2.xl_workbook)
        self.wb.set_current()
        assert_equal(Workbook.current().xl_workbook, self.wb.xl_workbook)
        wb2.close()

    def test_get_selection(self):
        Range('A1').value = 1000
        assert_equal(self.wb.get_selection().value, 1000)

    def test_reference_two_unsaved_wb(self):
        """Covers GH Issue #63"""
        wb1 = Workbook()
        wb2 = Workbook()

        Range('A1').value = 2.  # wb2
        Range('A1', wkb=wb1).value = 1.  # wb1

        assert_equal(Range('A1').value, 2.)
        assert_equal(Range('A1', wkb=wb1).value, 1.)

        wb1.close()
        wb2.close()

    def test_save_naked(self):

        cwd = os.getcwd()
        wb1 = Workbook()
        target_file_path = os.path.join(cwd, wb1.name + '.xlsx')
        if os.path.isfile(target_file_path):
            os.remove(target_file_path)

        wb1.save()

        assert_equal(os.path.isfile(target_file_path), True)

        wb2 = Workbook(target_file_path)
        wb2.close()

        if os.path.isfile(target_file_path):
            os.remove(target_file_path)

    def test_save_path(self):

        cwd = os.getcwd()
        wb1 = Workbook()
        target_file_path = os.path.join(cwd, 'TestFile.xlsx')
        if os.path.isfile(target_file_path):
            os.remove(target_file_path)

        wb1.save(target_file_path)

        assert_equal(os.path.isfile(target_file_path), True)

        wb2 = Workbook(target_file_path)
        wb2.close()

        if os.path.isfile(target_file_path):
            os.remove(target_file_path)
Exemple #4
0
class TestWorkbook:
    def setUp(self):
        # Connect to test file and make Sheet1 the active sheet
        xl_file1 = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'test_workbook_1.xlsx')
        self.wb = Workbook(xl_file1, app_visible=False, app_target=APP_TARGET)
        Sheet('Sheet1').activate()

    def tearDown(self):
        self.wb.close()

    def test_name(self):
        assert_equal(self.wb.name, 'test_workbook_1.xlsx')

    def test_active_sheet(self):
        assert_equal(self.wb.active_sheet.name, 'Sheet1')

    def test_current(self):
        assert_equal(self.wb.xl_workbook, Workbook.current().xl_workbook)

    def test_set_current(self):
        wb2 = Workbook(app_visible=False, app_target=APP_TARGET)
        assert_equal(Workbook.current().xl_workbook, wb2.xl_workbook)
        self.wb.set_current()
        assert_equal(Workbook.current().xl_workbook, self.wb.xl_workbook)
        wb2.close()

    def test_get_selection(self):
        Range('A1').value = 1000
        assert_equal(self.wb.get_selection().value, 1000)

    def test_reference_two_unsaved_wb(self):
        """Covers GH Issue #63"""
        wb1 = Workbook(app_visible=False, app_target=APP_TARGET)
        wb2 = Workbook(app_visible=False, app_target=APP_TARGET)

        Range('A1').value = 2.  # wb2
        Range('A1', wkb=wb1).value = 1.  # wb1

        assert_equal(Range('A1').value, 2.)
        assert_equal(Range('A1', wkb=wb1).value, 1.)

        wb1.close()
        wb2.close()

    def test_save_naked(self):

        cwd = os.getcwd()
        wb1 = Workbook(app_visible=False, app_target=APP_TARGET)
        target_file_path = os.path.join(cwd, wb1.name + '.xlsx')
        if os.path.isfile(target_file_path):
            os.remove(target_file_path)

        wb1.save()

        assert_equal(os.path.isfile(target_file_path), True)

        wb2 = Workbook(target_file_path, app_visible=False, app_target=APP_TARGET)
        wb2.close()

        if os.path.isfile(target_file_path):
            os.remove(target_file_path)

    def test_save_path(self):

        cwd = os.getcwd()
        wb1 = Workbook(app_visible=False, app_target=APP_TARGET)
        target_file_path = os.path.join(cwd, 'TestFile.xlsx')
        if os.path.isfile(target_file_path):
            os.remove(target_file_path)

        wb1.save(target_file_path)

        assert_equal(os.path.isfile(target_file_path), True)

        wb2 = Workbook(target_file_path, app_visible=False, app_target=APP_TARGET)
        wb2.close()

        if os.path.isfile(target_file_path):
            os.remove(target_file_path)

    def test_mock_caller(self):
        _skip_if_not_default_xl()

        Workbook.set_mock_caller(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'test_workbook_1.xlsx'))
        wb = Workbook.caller()
        Range('A1', wkb=wb).value = 333
        assert_equal(Range('A1', wkb=wb).value, 333)

    def test_unicode_path(self):
        # pip3 seems to struggle with unicode filenames
        src = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'unicode_path.xlsx')
        dst = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'ünicödé_päth.xlsx')
        shutil.move(src, dst)
        wb = Workbook(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'ünicödé_päth.xlsx'), app_target=APP_TARGET)
        Range('A1').value = 1
        wb.close()
        shutil.move(dst, src)

    def unsaved_workbook_reference(self):
        wb = Workbook(app_visible=False, app_target=APP_TARGET)
        Range('B2').value = 123
        wb2 = Workbook(wb.name, app_visible=False, app_target=APP_TARGET)
        assert_equal(Range('B2', wkb=wb2).value, 123)
Exemple #5
0
class TestWorkbook:
    def setUp(self):
        # Connect to test file and make Sheet1 the active sheet
        xl_file1 = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                'test_workbook_1.xlsx')
        self.wb = Workbook(xl_file1, app_visible=False, app_target=APP_TARGET)
        Sheet('Sheet1').activate()

    def tearDown(self):
        class_teardown(self.wb)

    def test_name(self):
        assert_equal(self.wb.name, 'test_workbook_1.xlsx')

    def test_active_sheet(self):
        assert_equal(self.wb.active_sheet.name, 'Sheet1')

    def test_current(self):
        assert_equal(self.wb.xl_workbook, Workbook.current().xl_workbook)

    def test_set_current(self):
        wb2 = Workbook(app_visible=False, app_target=APP_TARGET)
        assert_equal(Workbook.current().xl_workbook, wb2.xl_workbook)
        self.wb.set_current()
        assert_equal(Workbook.current().xl_workbook, self.wb.xl_workbook)
        wb2.close()

    def test_get_selection(self):
        Range('A1').value = 1000
        assert_equal(self.wb.get_selection().value, 1000)

    def test_reference_two_unsaved_wb(self):
        """Covers GH Issue #63"""
        wb1 = Workbook(app_visible=False, app_target=APP_TARGET)
        wb2 = Workbook(app_visible=False, app_target=APP_TARGET)

        Range('A1').value = 2.  # wb2
        Range('A1', wkb=wb1).value = 1.  # wb1

        assert_equal(Range('A1').value, 2.)
        assert_equal(Range('A1', wkb=wb1).value, 1.)

        wb1.close()
        wb2.close()

    def test_save_naked(self):

        cwd = os.getcwd()
        wb1 = Workbook(app_visible=False, app_target=APP_TARGET)
        target_file_path = os.path.join(cwd, wb1.name + '.xlsx')
        if os.path.isfile(target_file_path):
            os.remove(target_file_path)

        wb1.save()

        assert_equal(os.path.isfile(target_file_path), True)

        wb2 = Workbook(target_file_path,
                       app_visible=False,
                       app_target=APP_TARGET)
        wb2.close()

        if os.path.isfile(target_file_path):
            os.remove(target_file_path)

    def test_save_path(self):

        cwd = os.getcwd()
        wb1 = Workbook(app_visible=False, app_target=APP_TARGET)
        target_file_path = os.path.join(cwd, 'TestFile.xlsx')
        if os.path.isfile(target_file_path):
            os.remove(target_file_path)

        wb1.save(target_file_path)

        assert_equal(os.path.isfile(target_file_path), True)

        wb2 = Workbook(target_file_path,
                       app_visible=False,
                       app_target=APP_TARGET)
        wb2.close()

        if os.path.isfile(target_file_path):
            os.remove(target_file_path)

    def test_mock_caller(self):
        # Can't really run this one with app_visible=False
        _skip_if_not_default_xl()

        Workbook.set_mock_caller(
            os.path.join(os.path.dirname(os.path.abspath(__file__)),
                         'test_workbook_1.xlsx'))
        wb = Workbook.caller()
        Range('A1', wkb=wb).value = 333
        assert_equal(Range('A1', wkb=wb).value, 333)

    def test_unicode_path(self):
        # pip3 seems to struggle with unicode filenames
        src = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                           'unicode_path.xlsx')
        dst = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                           'ünicödé_päth.xlsx')
        shutil.move(src, dst)
        wb = Workbook(os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                   'ünicödé_päth.xlsx'),
                      app_visible=False,
                      app_target=APP_TARGET)
        Range('A1').value = 1
        wb.close()
        shutil.move(dst, src)

    def test_unsaved_workbook_reference(self):
        wb = Workbook(app_visible=False, app_target=APP_TARGET)
        Range('B2').value = 123
        wb2 = Workbook(wb.name, app_visible=False, app_target=APP_TARGET)
        assert_equal(Range('B2', wkb=wb2).value, 123)
        wb2.close()

    def test_delete_named_item(self):
        Range('B10:C11').name = 'to_be_deleted'
        assert_equal(Range('to_be_deleted').name, 'to_be_deleted')
        del self.wb.names['to_be_deleted']
        assert_not_equal(Range('B10:C11').name, 'to_be_deleted')

    def test_names_collection(self):
        Range('A1').name = 'name1'
        Range('A2').name = 'name2'
        assert_true('name1' in self.wb.names and 'name2' in self.wb.names)

        Range('A3').name = 'name3'
        assert_true('name1' in self.wb.names and 'name2' in self.wb.names
                    and 'name3' in self.wb.names)

    def test_active_workbook(self):
        # TODO: add test over multiple Excel instances on Windows
        Range('A1').value = 'active_workbook'
        wb_active = Workbook.active(app_target=APP_TARGET)
        assert_equal(Range('A1', wkb=wb_active).value, 'active_workbook')

    def test_workbook_name(self):
        Range('A10').value = 'name-test'
        wb2 = Workbook('test_workbook_1.xlsx',
                       app_visible=False,
                       app_target=APP_TARGET)
        assert_equal(Range('A10', wkb=wb2).value, 'name-test')
Exemple #6
0
class TestWorkbook:
    def setUp(self):
        # Connect to test file and make Sheet1 the active sheet
        xl_file1 = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'test_workbook_1.xlsx')
        self.wb = Workbook(xl_file1, app_visible=False)
        Sheet('Sheet1').activate()

    def tearDown(self):
        self.wb.close()

    def test_name(self):
        assert_equal(self.wb.name, 'test_workbook_1.xlsx')

    def test_active_sheet(self):
        assert_equal(self.wb.active_sheet.name, 'Sheet1')

    def test_current(self):
        assert_equal(self.wb.xl_workbook, Workbook.current().xl_workbook)

    def test_set_current(self):
        wb2 = Workbook(app_visible=False)
        assert_equal(Workbook.current().xl_workbook, wb2.xl_workbook)
        self.wb.set_current()
        assert_equal(Workbook.current().xl_workbook, self.wb.xl_workbook)
        wb2.close()

    def test_get_selection(self):
        Range('A1').value = 1000
        assert_equal(self.wb.get_selection().value, 1000)

    def test_reference_two_unsaved_wb(self):
        """Covers GH Issue #63"""
        wb1 = Workbook(app_visible=False)
        wb2 = Workbook(app_visible=False)

        Range('A1').value = 2.  # wb2
        Range('A1', wkb=wb1).value = 1.  # wb1

        assert_equal(Range('A1').value, 2.)
        assert_equal(Range('A1', wkb=wb1).value, 1.)

        wb1.close()
        wb2.close()

    def test_save_naked(self):

        cwd = os.getcwd()
        wb1 = Workbook(app_visible=False)
        target_file_path = os.path.join(cwd, wb1.name + '.xlsx')
        if os.path.isfile(target_file_path):
            os.remove(target_file_path)

        wb1.save()

        assert_equal(os.path.isfile(target_file_path), True)

        wb2 = Workbook(target_file_path, app_visible=False)
        wb2.close()

        if os.path.isfile(target_file_path):
            os.remove(target_file_path)

    def test_save_path(self):

        cwd = os.getcwd()
        wb1 = Workbook(app_visible=False)
        target_file_path = os.path.join(cwd, 'TestFile.xlsx')
        if os.path.isfile(target_file_path):
            os.remove(target_file_path)

        wb1.save(target_file_path)

        assert_equal(os.path.isfile(target_file_path), True)

        wb2 = Workbook(target_file_path, app_visible=False)
        wb2.close()

        if os.path.isfile(target_file_path):
            os.remove(target_file_path)
Exemple #7
0
class TestWorkbook:
    def setUp(self):
        # Connect to test file and make Sheet1 the active sheet
        xl_file1 = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'test_workbook_1.xlsx')
        self.wb = Workbook(xl_file1, app_visible=False, app_target=APP_TARGET)
        Sheet('Sheet1').activate()

    def tearDown(self):
        class_teardown(self.wb)

    def test_name(self):
        assert_equal(self.wb.name, 'test_workbook_1.xlsx')

    def test_active_sheet(self):
        assert_equal(self.wb.active_sheet.name, 'Sheet1')

    def test_current(self):
        assert_equal(self.wb.xl_workbook, Workbook.current().xl_workbook)

    def test_set_current(self):
        wb2 = Workbook(app_visible=False, app_target=APP_TARGET)
        assert_equal(Workbook.current().xl_workbook, wb2.xl_workbook)
        self.wb.set_current()
        assert_equal(Workbook.current().xl_workbook, self.wb.xl_workbook)
        wb2.close()

    def test_get_selection(self):
        Range('A1').value = 1000
        assert_equal(self.wb.get_selection().value, 1000)

    def test_reference_two_unsaved_wb(self):
        """Covers GH Issue #63"""
        wb1 = Workbook(app_visible=False, app_target=APP_TARGET)
        wb2 = Workbook(app_visible=False, app_target=APP_TARGET)

        Range('A1').value = 2.  # wb2
        Range('A1', wkb=wb1).value = 1.  # wb1

        assert_equal(Range('A1').value, 2.)
        assert_equal(Range('A1', wkb=wb1).value, 1.)

        wb1.close()
        wb2.close()

    def test_save_naked(self):
        if sys.platform.startswith('darwin'):
            folder = os.path.expanduser("~") + '/Library/Containers/com.microsoft.Excel/Data/'
            if os.path.isdir(folder):
                os.chdir(folder)

        cwd = os.getcwd()
        wb1 = Workbook(app_visible=False, app_target=APP_TARGET)
        target_file_path = os.path.join(cwd, wb1.name + '.xlsx')
        if os.path.isfile(target_file_path):
            os.remove(target_file_path)

        wb1.save()

        assert_equal(os.path.isfile(target_file_path), True)

        wb2 = Workbook(target_file_path, app_visible=False, app_target=APP_TARGET)
        wb2.close()

        if os.path.isfile(target_file_path):
            os.remove(target_file_path)

    def test_save_path(self):
        if sys.platform.startswith('darwin'):
            folder = os.path.expanduser("~") + '/Library/Containers/com.microsoft.Excel/Data/'
            if os.path.isdir(folder):
                os.chdir(folder)

        cwd = os.getcwd()
        wb1 = Workbook(app_visible=False, app_target=APP_TARGET)
        target_file_path = os.path.join(cwd, 'TestFile.xlsx')
        if os.path.isfile(target_file_path):
            os.remove(target_file_path)

        wb1.save(target_file_path)

        assert_equal(os.path.isfile(target_file_path), True)

        wb2 = Workbook(target_file_path, app_visible=False, app_target=APP_TARGET)
        wb2.close()

        if os.path.isfile(target_file_path):
            os.remove(target_file_path)

    def test_mock_caller(self):
        # Can't really run this one with app_visible=False
        _skip_if_not_default_xl()

        Workbook.set_mock_caller(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'test_workbook_1.xlsx'))
        wb = Workbook.caller()
        Range('A1', wkb=wb).value = 333
        assert_equal(Range('A1', wkb=wb).value, 333)

    def test_unicode_path(self):
        # pip3 seems to struggle with unicode filenames
        src = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'unicode_path.xlsx')
        if sys.platform.startswith('darwin') and os.path.isdir(os.path.expanduser("~") + '/Library/Containers/com.microsoft.Excel/Data/'):
            dst = os.path.join(os.path.expanduser("~") + '/Library/Containers/com.microsoft.Excel/Data/',
                           'ünicödé_päth.xlsx')
        else:
            dst = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'ünicödé_päth.xlsx')
        shutil.copy(src, dst)
        wb = Workbook(dst, app_visible=False, app_target=APP_TARGET)
        Range('A1').value = 1
        wb.close()
        os.remove(dst)

    def test_unsaved_workbook_reference(self):
        wb = Workbook(app_visible=False, app_target=APP_TARGET)
        Range('B2').value = 123
        wb2 = Workbook(wb.name, app_visible=False, app_target=APP_TARGET)
        assert_equal(Range('B2', wkb=wb2).value, 123)
        wb2.close()

    def test_delete_named_item(self):
        Range('B10:C11').name = 'to_be_deleted'
        assert_equal(Range('to_be_deleted').name, 'to_be_deleted')
        del self.wb.names['to_be_deleted']
        assert_not_equal(Range('B10:C11').name, 'to_be_deleted')

    def test_names_collection(self):
        Range('A1').name = 'name1'
        Range('A2').name = 'name2'
        assert_true('name1' in self.wb.names and 'name2' in self.wb.names)

        Range('A3').name = 'name3'
        assert_true('name1' in self.wb.names and 'name2' in self.wb.names and
                    'name3' in self.wb.names)

    def test_active_workbook(self):
        # TODO: add test over multiple Excel instances on Windows
        Range('A1').value = 'active_workbook'
        wb_active = Workbook.active(app_target=APP_TARGET)
        assert_equal(Range('A1', wkb=wb_active).value, 'active_workbook')

    def test_workbook_name(self):
        Range('A10').value = 'name-test'
        wb2 = Workbook('test_workbook_1.xlsx', app_visible=False, app_target=APP_TARGET)
        assert_equal(Range('A10', wkb=wb2).value, 'name-test')