question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Assert, getter function always fail with expecting a property

See original GitHub issue

For 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:closed
  • Created 6 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
sukrosonocommented, Nov 21, 2017

Assign me Cap, working on it.

I have a question, the 3rd param was written optional but when we use the getterFn i feel like need to have the 3rd param. Then here still need 4th param delta. I found it awkward when we use assert(fn, getterFn, null, 1) for example. The 3rd param property as optional also found on several function, any advice?

0reactions
lucasfcostacommented, Jun 9, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found