Assert, getter function always fail with expecting a property
See original GitHub issueFor the reproduction shake only assert.decreasesBy
. See reproduction, line 16 pass; 18, 19 both fail.
AssertionError: 1: expected [Function: fn] to have property ‘x’
But i suspecting:
- assert.decreasesButNotBy
- assert.increasesBy
- assert.increasesButNotBy
When use getter function, let me know if i am wrong. Discovered when made #1085 to aim #1084.
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Unit Test passes with setter only property, failing by just ...
c# - Unit Test passes with setter only property, failing by just adding getter to the property - Stack Overflow. Stack Overflow for...
Read more >Python's assert: Debug and Test Your Code Like a Pro
In this tutorial, you'll learn how to use Python's assert statement to document, debug, and test code in development.
Read more >Assertion Styles - Chai
Assertion Styles. This section of the guide introduces you to the three different assertion styles that you may use in your testing environment....
Read more >Avoid getters and setters whenever possible
The argument is that getters/setters and properties VIOLATE ENCAPSULATION by exposing internals as properties rather than mutating through ...
Read more >Python static code analysis: Property getter, setter and deleter ...
Property getter, setter and deleter methods should have the expected number of parameters ... Assertions should not fail or succeed unconditionally.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Assign me Cap, working on it.
I have a question, the 3rd param was written
optional
but when we use thegetterFn
i feel like need to have the 3rd param. Then here still need 4th paramdelta
. I found it awkward when we useassert(fn, getterFn, null, 1)
for example. The 3rd paramproperty
as optional also found on several function, any advice?Since me and @keithamus are cleaning up issues I’ll close this because it will go into the roadmap.
As I demonstrated before, asserting on properties of functions is a valid use case.
I also mentioned that we can actually see if users did pass a property name or not by checking the number of arguments. If users pass 3 arguments then it means the third one is a value, not a property name (after all
decreasesBy
implies you will have to pass an argument which tells the delta). So this is what we’re going to do.