-
Notifications
You must be signed in to change notification settings - Fork 55
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
This PR aims to fix Issue #233 #292
Conversation
…Used TestArguments
@EricLiclair build seems to break for Python3.9 |
@deathowl I did notice the failed build test, but i am not sure why is that happening. I checked the test log and found that Also, the make instruction successfully executes in my system. I wonder where am I going wrong. I also forked the master repo from my second account just to be sure I was not missing anything, added my changes and dropped a PR. Seems the build failed for that PR as well. I am kind of stuck. I'll be looking into this, but your comments would be appreciated. |
Pull Request Test Coverage Report for Build 695782107
💛 - Coveralls |
tests/matchers_unittest.py
Outdated
self.assertEqual(testslide.matchers.FloatBetween(2.1, 666.0), 4.2) | ||
self.assertEqual(testslide.matchers.FloatBetween(2.1, 666.0), 2.1) | ||
self.assertEqual(testslide.matchers.FloatBetween(21.0, 66.6), 66.6) |
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.
This is where the tests were updated as the argument used 666
was not of type float
.
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 need to go through all the PR to fully review it.
a suggestion that I would provide, by checking this test, I'd that it would consider acceptable to have integers in the bounds of FloatBeetween
, after all the intention is to get numbers (floats) within 2 ranges.
The same comment will apply to greater and lesser matchers as well as for IntBetween
@@ -265,7 +313,7 @@ def __init__(self) -> None: | |||
|
|||
class RegexMatches(Matcher): | |||
""" | |||
Compares true if other mathes given regex. | |||
Compares true if other matches given regex. | |||
""" | |||
|
|||
def __init__(self, pattern: str, flags: int = 0) -> None: |
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.
What I would like to mention is that, adding a type check here was the reason the build was failing. I wonder why was it so. And hence I couldn't add a type check here. Any comments on this will be appreciated.
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 I'm following you ... what failure specifically are you referring to?
Checking the history of your commits I see that the code was something like
def __init__(self, pattern: str, flags: int = 0) -> None:
if not isinstance(pattern, str) or not isinstance(flags, int):
raise ValueError(
f"RegexMatches(...) expects 'str' and 'int' as arguments while '{type(pattern).__name__}' and '{type(flags).__name__}' were provided"
)
...
how is this causing random test failures?
Side (and personal) note: to make the code-review easier I would suggest to limit merging master branch in your branch.
This because it makes harder to trace changes and makes the history more confusing. Clearly, this does not mean that you should not be doing it but do it parsimoniously.
I do tend to use git rebase
on the PR branch if the PR takes a very long time to be reviewed and merged in order to gather all the updates.
If a PR is short-living it would be unlikely to have failures caused by other changes and anyway when github actions runs tests they are run on top of your branch merged with master, so tests will detect if your changes would cause test failures caused by new code.
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.
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.
In fact all of the commits were failing build test, until the last one.
@deathowl hey, sorry that it took a lot of time figuring out what went wrong. Also, @macisamuele I believe this should work. ☺ |
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.
@EricLiclair thanks a lot for your PR.
I do like the general approach used, I would just relax a little bit the constraints here in order to not have a huge toll on developers using it.
I would still be curious to understand what was causing the test failures. Is this something that we can address in this PR such that we can re-add the ValueError
throwing into RegexMatches
as well?
testslide/matchers.py
Outdated
super().__init__(ne=ne) | ||
|
||
|
||
class IntBetween(_IntComparison): | ||
def __init__(self, lower: int, upper: int) -> None: | ||
if not isinstance(lower, int) or not isinstance(upper, int): |
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 would personally allow float values as well.
I mean what if I'm looking for any integer between 2.8 and 33.9 ?
Think about a case like
def test_dummy(self) -> None:
lower = some_calculation() # This returns a number, maybe an integer value but probably stored in float
upper = lower * 2
IntBetween(lower, upper) # This would fail, but from a conceptual point of view it might be valid
This comment is valid for all the Int* matchers
testslide/matchers.py
Outdated
super().__init__(ne=ne) | ||
|
||
|
||
class FloatBetween(_FloatComparison): | ||
def __init__(self, lower: float, upper: float) -> None: | ||
if not isinstance(lower, float) or not isinstance(upper, float): |
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 would allow integers values as well.
The same reasoning of IntBetween
holds in this case.
Let's say that I want to match any number that is between 0 and 100 ... why should I be forced to represent them as floats?
tests/matchers_unittest.py
Outdated
with self.assertRaises(ValueError): | ||
testslide.matchers.IntGreaterThan(42.42) |
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 would not make it fail in this case ...
The "concept" here is to have all the integer bigger than 42.42
so numbers like 43, 44, etc. I would say that constraining floats away from here would require users of the matchers to make more gymnastics with floor
/ceil
/int
which might end up with tests that would be less obvious to be read
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.
Insightful, I really missed out the point that both float
and integer
values can be valid range extremes. I'll try to update accordingly as per the comments you mentioned. Thanks for your review. ☺
@deathowl : do you have strong opinion against ensuring that we still run full tests on all the python versions even if a single version failed? |
@macisamuele i'll resurrect Fabios Tox diff, and make it work for running all our tests . I think running against all supported py versions is strong signal |
…led (#295) Summary: **What:** Ensure that we do run all the tests (platforms/python-versions) and that we don't immediately stop if one has failed. This is a follow-up from #292 **Why:** In case of test failures is extremely interesting to have information about "is this failure a genuine bug or is an issue with a single python version?". **How:** Ensure that github workflow is correctly defined. Doc in [here](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstrategyfail-fast) **Risks:** n/a **Checklist**: - [x] Added tests, if you've added code that should be tested - [x] Updated the documentation, if you've changed APIs - [x] Ensured the test suite passes - [x] Made sure your code lints - [x] Completed the Contributor License Agreement ("CLA") Pull Request resolved: #295 Reviewed By: deathowl Differential Revision: D27395399 Pulled By: macisamuele fbshipit-source-id: e474f46614b5422c798b0fcfbd73edab58a9e007
Hey @EricLiclair build still seems broken to me |
@deathowl @macisamuele Sorry for being unavailable for the past few months. Hard times. |
Closing because resubmitted in #303 |
What:
Fix for issue #233
testAnyFloat
,testNotEmptyList
andtestEmptyList
Why:
How:
For point 1
Checked for the passed arguments to be of the specified types. If not, raised a
ValueError
with appropriate error message.Risks:
N/A. At least not intentionally.
Checklist: