-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Conversation
catmar22
commented
Dec 6, 2022
•
edited by mroeschke
Loading
edited by mroeschke
- closes TST: Subclasses of ExcelWriter should not be allowed to add new public attributes #49602
- not fully tested with style and pre-commit checks yet
…on't have public attributes
@@ -30,6 +30,9 @@ | |||
register_writer, | |||
) | |||
|
|||
# added for last test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment isn't needed
@@ -1353,3 +1356,12 @@ def test_excelwriter_fspath(self): | |||
with tm.ensure_clean("foo.xlsx") as path: | |||
with ExcelWriter(path) as writer: | |||
assert os.fspath(writer) == str(path) | |||
|
|||
# testing that subclasses of ExcelWriter don't have public attributes (issue 49602) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you put this in the testing function?
def test_subclass_attr(klass): | ||
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 attrs_base.symmetric_difference(attrs_klass) == set() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert attrs_base.symmetric_difference(attrs_klass) == set() | |
assert not attrs_base.symmetric_difference(attrs_klass) |
I am failing the pre-commit check and from what I saw in the results of the tests this time, I think it has to do with the import statement? Do you have any input on what the issue might be, ie did I put it in a bad spot based on certain code style/maintenance criteria? Or where I could look for further documentation on this? |
Thanks @catmar22 |
Thanks @catmar22! |