-
Notifications
You must be signed in to change notification settings - Fork 801
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
parser: ensure samples are of type Sample #358
parser: ensure samples are of type Sample #358
Conversation
ac48657
to
628c877
Compare
Why does assertEqual not work? |
@brian-brazil because |
If you want to test for the named attributes, then I suggest testing for them as that's more in line with Python's duck typing. |
I have 3 arguments against "testing the ducktype" here: MaintainabilityWell, then we have to keep the tests and the Robustness / Clean CodeNot sure how sane that would be. As a user, I basically expect:
which is exactly the definition of
Type ZooWe have a single library here and I think this single library should use a single type for that dedicated purpose (= representing samples). This partly contradicts ducktyping (in the provider/return part) but is nice for contributors to understand the library and for users to grasp the concepts. Also, it would make type annotations way easier in the future (in case we want to walk that path). Notice that consistent types make downstream libraries also simpler (since they can use type annotations) and enables proper IDE support. If this doesn't convince you, I can change the tests. Just let me know and thank you for your time and effort. |
I'd prefer to keep the tests simple. |
Then I don't understand. Your proposed solution to just test (all) named attributes is not simpler than the isinstance test. It's more code and more maintenance burden. |
I'm suggesting using assertEquals, and you want to check specific types are right verify that they have one of the named attributes. |
Alright then. Even though I very much disagree with you, I'll change the test when I'm back in the office (Monday). |
628c877
to
93ca545
Compare
done |
In one or two tests is enough. |
Not sure this is enough. The problem is that the return type was |
assert type(first) == type(second) | ||
for a, b in zip(first, second): | ||
for sa, sb in zip(a.samples, b.samples): | ||
assert sa.name == sb.name |
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.
Can you add a comment as to why you're doing this?
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.
That's a bit lengthy, you only need to say that you're checking the type is correct.
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.
done
93ca545
to
30a38f4
Compare
I wanted to chime in with a 'nice catch' on this and add my vote for moving this to a release as soon as reasonable. |
Signed-off-by: Marco Neumann <marco.neumann@blue-yonder.com>
30a38f4
to
e180e1d
Compare
Thanks! |
No description provided.