Skip to content

Commit 7b2dd38

Browse files
authored
TST: added test to ensure subclasses of ExcelWriter don't add any public attributes (#50097)
* added test relating to issue 49602 to ensure ExcelWrtier subclasses don't have public attributes * revised test for ExceWriter subclasses according to feedback from #50097 * same test for ExcelWriter subclass but with pre-commit check (#50097)
1 parent 16b9c98 commit 7b2dd38

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pandas/tests/io/excel/test_writers.py

+9
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
_XlsxWriter,
3030
register_writer,
3131
)
32+
from pandas.io.excel._util import _writers
3233

3334

3435
@pytest.fixture
@@ -1351,3 +1352,11 @@ def test_excelwriter_fspath(self):
13511352
with tm.ensure_clean("foo.xlsx") as path:
13521353
with ExcelWriter(path) as writer:
13531354
assert os.fspath(writer) == str(path)
1355+
1356+
1357+
@pytest.mark.parametrize("klass", _writers.values())
1358+
def test_subclass_attr(klass):
1359+
# testing that subclasses of ExcelWriter don't have public attributes (issue 49602)
1360+
attrs_base = {name for name in dir(ExcelWriter) if not name.startswith("_")}
1361+
attrs_klass = {name for name in dir(klass) if not name.startswith("_")}
1362+
assert not attrs_base.symmetric_difference(attrs_klass)

0 commit comments

Comments
 (0)