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
ENH: Make exception thrown by re a bit more informative #4398
Conversation
Codecov Report
@@ Coverage Diff @@
## maint #4398 +/- ##
==========================================
+ Coverage 89.63% 89.67% +0.03%
==========================================
Files 275 275
Lines 37054 37064 +10
==========================================
+ Hits 33215 33236 +21
+ Misses 3839 3828 -11
Continue to review full report at Codecov.
|
Some minor comments on the tests. The end result in terms of error message is a nice improvement.
@@ -68,6 +71,7 @@ def test_search_outside1(tdir, newhome): | |||
next(search("bu", dataset=newhome)) | |||
|
|||
|
|||
|
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.
Spurious extra space introduced by first commit.
def test_our_metadataset_search(tdir): | ||
# TODO renable when a dataset with new aggregated metadata is | ||
# available at some public location | ||
raise SkipTest |
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.
Okay, so this looks to be clean-up of an unrelated test. Based on the comment, it was skipped with the hopes of re-enabling it, but I'm guessing that's a stale expectation for some reason. I can't figure out what that is from the commit message, though:
RF: completely stripping skipped test_our_metadataset_search - will be used in /// itself
In particular, I don't understand what "will be used in /// itself" means.
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 am adding such tests to http://datasets.datalad.org/ repository itself, and will add a run on it to datalad-extensions. We could even add it to our workflows in this repository.
Indeed it is unrelated. will do a dance to submit it into a separate PR
with assert_raises(ValueError) as cme: | ||
ds.search('*wrong') | ||
assert_re_in( | ||
'regular expression .\(\?i\)\*wrong. \(original: .\*wrong.\) is incorrect:', |
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.
You're missing an 'r' prefix here. Since Python 3.6, these will give a deprecation warning:
W605 invalid escape sequence '\('
W605 invalid escape sequence '\?'
W605 invalid escape sequence '\)'
W605 invalid escape sequence '\*'
W605 invalid escape sequence '\('
W605 invalid escape sequence '\*'
W605 invalid escape sequence '\)'
The .
s in the regular expression made me pause. They match '
. Given that it's our code that's adding these quotes, why not just match them explicitly, as we're already doing for the rest of the message?
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.
couldn't they also be "
? At least in python2 repr
could have produce one or another IIRC.
So, it was my lazy way to catch both, relaxing a bit too much. Will make it strict
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.
doh -- I do not use repr
;) so can indeed just place '
It will now include actual regular expression which lead to the failure, since we could have multiple specified
Fixes #4393
So now we would get something like
instead of
While at it -- completely removed skipped test. It was disabled for a while, and it depends on the external resource (our
///
) so could be flaky without our code changes, and takes awhile.