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

get rid of the None engine tests and just have a separate test that ensures how that gets bound to a particular engine #26662 (comment) #28749

Closed

Conversation

ladyyvii
Copy link
Contributor

@ladyyvii ladyyvii commented Oct 2, 2019

@simonjayhawkins simonjayhawkins added Clean IO Excel read_excel, to_excel Testing pandas testing functions or related to the test suite labels Oct 2, 2019
Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

@@ -67,6 +60,24 @@ def engine(request):
return request.param


@pytest.mark.parametrize("kwargs", [dict(), dict(engine=None)])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea but I think the parametrization here is overkill so OK to remove

@@ -67,6 +60,24 @@ def engine(request):
return request.param


@pytest.mark.parametrize("kwargs", [dict(), dict(engine=None)])
def test_default_engine(datapath, monkeypatch, kwargs):
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use docstrings for tests so OK to remove this as well. You can add the issue number as a comment instead

expected = "xlrd"

result = pd.ExcelFile("blank.xls", **kwargs)
assert result.engine == expected
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works for ExcelFile - can you think of a way to test this for pd.read_excel as well?

Copy link
Contributor Author

@ladyyvii ladyyvii Oct 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this test does testing implicitly for the default value of the engine parameter (which is None) for pd.read_excel as well, because under the hood pd.read_excel either creates an instance of the ExcelFile class and passes the engine parameter value to it or is provided with an ExcelFile instance through the io parameter:

    if not isinstance(io, ExcelFile):
        io = ExcelFile(io, engine=engine)
    elif engine and engine != io.engine:
        raise ValueError(
            "Engine should not be specified when passing "
            "an ExcelFile - ExcelFile already has the engine set"
        )

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea I just think that's fragile to always assume that's how this implementation will work - we'd lose coverage and expose ourselves to bugs if this gets refactored

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree with you. I'll try to figure out a way to test read_excel as well, but I'm afraid it's not gonna be pretty...

pandas/tests/io/excel/test_readers.py Show resolved Hide resolved
@WillAyd
Copy link
Member

WillAyd commented Nov 7, 2019

Thanks for the PR. I think this is OK as is in master though, so let's table this for now

@WillAyd WillAyd closed this Nov 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean IO Excel read_excel, to_excel Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants