Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: openpyxl tests fail if xlrd is not installed #27111

Closed
jorisvandenbossche opened this issue Jun 28, 2019 · 0 comments · Fixed by #27114
Closed

TST: openpyxl tests fail if xlrd is not installed #27111

jorisvandenbossche opened this issue Jun 28, 2019 · 0 comments · Fixed by #27114
Labels
IO Excel read_excel, to_excel Testing pandas testing functions or related to the test suite
Milestone

Comments

@jorisvandenbossche
Copy link
Member

If you run the tests/io/excel/test_readers.py with only openpyxl installed, the xlrd tests are skipped, but some of the openpyxl tests still fail on needing xlrd.

eg:

____________________________________________________________ TestExcelFileRead.test_read_excel_engine_value[openpyxl-.xlsm-None] _____________________________________________________________

self = <pandas.tests.io.excel.test_readers.TestExcelFileRead object at 0x7fca3bb6d198>, read_ext = '.xlsm', excel_engine = None

    @pytest.mark.parametrize('excel_engine', [
        'xlrd',
        None
    ])
    def test_read_excel_engine_value(self, read_ext, excel_engine):
        # GH 26566
>       xl = ExcelFile("test1" + read_ext, engine=excel_engine)

../excel/test_readers.py:853: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../../io/excel/_base.py:791: in __init__
    self._reader = self._engines[engine](self._io)
../../../io/excel/_xlrd.py:21: in __init__
    import_optional_dependency("xlrd", extra=err_msg)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

name = 'xlrd', extra = 'Install xlrd >= 1.0.0 for Excel support', raise_on_missing = True, on_version = 'raise'

    def import_optional_dependency(
        name: str,
        extra: str = "",
        raise_on_missing: bool = True,
        on_version: str = "raise",
    ):
        """
        Import an optional dependency.
    
        By default, if a dependency is missing an ImportError with a nice
        message will be raised. If a dependency is present, but too old,
        we raise.
    
        Parameters
        ----------
        name : str
            The module name. This should be top-level only, so that the
            version may be checked.
        extra : str
            Additional text to include in the ImportError message.
        raise_on_missing : bool, default True
            Whether to raise if the optional dependency is not found.
            When False and the module is not present, None is returned.
        on_version : str {'raise', 'warn'}
            What to do when a dependency's version is too old.
    
            * raise : Raise an ImportError
            * warn : Warn that the version is too old. Returns None
            * ignore: Return the module, even if the version is too old.
              It's expected that users validate the version locally when
              using ``on_version="ignore"`` (see. ``io/html.py``)
    
        Returns
        -------
        maybe_module : Optional[ModuleType]
            The imported module, when found and the version is correct.
            None is returned when the package is not found and `raise_on_missing`
            is False, or when the package's version is too old and `on_version`
            is ``'warn'``.
        """
        try:
            module = importlib.import_module(name)
        except ImportError:
            if raise_on_missing:
>               raise ImportError(message.format(name=name, extra=extra)) from None
E               ImportError: Missing optional dependency 'xlrd'. Install xlrd >= 1.0.0 for Excel support Use pip or conda to install xlrd.

The actual excel reading (interactively) is not affected, so certainly not a blocking issue.

@jorisvandenbossche jorisvandenbossche added IO Excel read_excel, to_excel Testing pandas testing functions or related to the test suite labels Jun 28, 2019
@jreback jreback added this to the 0.25.0 milestone Jun 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO Excel read_excel, to_excel Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants