Skip to content

TST: added test to ensure subclasses of ExcelWriter don't add any public attributes #50097

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

Merged
merged 8 commits into from
Dec 12, 2022
9 changes: 9 additions & 0 deletions pandas/tests/io/excel/test_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
_XlsxWriter,
register_writer,
)
from pandas.io.excel._util import _writers


@pytest.fixture
Expand Down Expand Up @@ -1351,3 +1352,11 @@ def test_excelwriter_fspath(self):
with tm.ensure_clean("foo.xlsx") as path:
with ExcelWriter(path) as writer:
assert os.fspath(writer) == str(path)


@pytest.mark.parametrize("klass", _writers.values())
def test_subclass_attr(klass):
# testing that subclasses of ExcelWriter don't have public attributes (issue 49602)
attrs_base = {name for name in dir(ExcelWriter) if not name.startswith("_")}
attrs_klass = {name for name in dir(klass) if not name.startswith("_")}
assert not attrs_base.symmetric_difference(attrs_klass)