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
ItemAdapter.get_field_names_from_class #64
Conversation
Codecov Report
@@ Coverage Diff @@
## master #64 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 4 4
Lines 291 318 +27
=========================================
+ Hits 291 318 +27
Help us with your feedback. Take ten seconds to tell us how you rate us. |
@@ -43,10 +43,13 @@ def test_module_import_error(self): | |||
from itemadapter.adapter import DataclassAdapter | |||
|
|||
self.assertFalse(DataclassAdapter.is_item(DataClassItem(name="asdf", value=1234))) | |||
with self.assertRaises(RuntimeError, msg="attr module is not available"): | |||
with self.assertRaises(RuntimeError, msg="dataclasses module is not available"): |
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.
I'm not sure why it's been passing. Probably, assertRaises doesn't work as intended here.
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.
I believe that is the message that shows if the assert fails. We can use assertRaisesRegex
if the goal is for the assert of fail if the exception message does not match this one.
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.
Nice!
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.
Looks good @kmike, thanks! Should I release now with this or is there anything else you need?
Thanks for merging it @elacuesta! |
Awesome, thanks @elacuesta! |
hey! This PR adds a new ItemAdapter classmethod: get_field_names_from_class - similar to get_field_names, but accepts item class, not an item itself. It's motivated by scrapinghub/web-poet#53 (comment).