Fixed anti-pattern in writer function#85
Conversation
Codecov Report
@@ Coverage Diff @@
## master #85 +/- ##
==========================================
+ Coverage 99.16% 99.17% +<.01%
==========================================
Files 6 6
Lines 361 363 +2
Branches 116 117 +1
==========================================
+ Hits 358 360 +2
Misses 1 1
Partials 2 2
Continue to review full report at Codecov.
|
|
I understand the issue and how it can cause problems, but I'm not sure I see how the test adequately tests the problem. Can you explain? My expectation for a test would be calling |
|
The purpose of the test was not to cover the mentioned bug (since it's already fixed). It was mostly to cover the case of having no header argument (Codecov complained). But you're right, there could be a point in testing repeated invocations. |
|
Oh okay. With new features/bug fixes, the goal is to add a test that fails before the fix and succeeds after the fix. That way if someone adds some code down the line that messes this up, it will fail again. That should also fix the codecov problem too! |
|
Hm, I'm a bit unsure how such a test case would look though. The thing is, there were no cases where this was actually breaking stuff since you were always overwriting the same fields with the same values. However, this is simply bad practice and could possibly lead to problems in the future. A related thing, outputs I don't know if this is intended. |
|
Oh okay, I was curious whether there were any use cases where it would actually fail because we do overwrite the fields each time. I think I'm fine with how it's setup then. The test you've added tests the Not sure if it's intended either, but I kinda like that functionality because then we know what parameters were saved after the fact. What do you think? Maybe it's worth documenting that functionality to be safe. I'll merge this PR tonight in case we want to continue having a conversation here. Edit: Feel free to add yourself to the |
|
Great! As for the header being mutable, I guess there could be some problems if users want to reuse the header object. However, as long as it is documented it should be fine I guess. There is some point in allowing the user to inspect the output header, as you mentioned. I will take you up on that, thanks! 😃 |
Fixed a bug in the writer function where the header data was persistent between calls (see this for further info).