-
Notifications
You must be signed in to change notification settings - Fork 300
Correct STASH regular expression #2638
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
Conversation
This reverts commit 8e02c7a.
|
hello @ehogan the code lines are being hit in these test cases perhaps you could add a test, using one of these partial strings, e.g. and compare behaviour of the current regular expression to your proposed change; perhaps there's a small behaviour tweak that you could implement |
|
Just one set of tests failed due to time out errors. Do the tests need to be restarted? I'm pretty sure everything is ok though. Thank you for the help @marqh! :) |
DPeterK
left a comment
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.
Thanks for this update @ehogan - I've made a comment on something I'd like to see improved, but if you'd prefer not to make that improvement I quite understand!
lib/iris/tests/test_pp_stash.py
Outdated
| self.assertEqual('abc', iris.fileformats.pp.STASH(1, 2, 3)) | ||
|
|
||
| with self.assertRaises(ValueError): | ||
| self.assertEqual(iris.fileformats.pp.STASH(1, 2, 3), 'mlotstmin') |
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.
So I realise that this isn't directly your problem as you've copied an existing pattern, it's just the pattern you've copied is quite unusual... What this is doing is using one of the unittest assertions to catch an error raised by another unittest assertion 😱
I would prefer to see something like the following in all of these cases:
test_val = 'mlotstmin'
exp_emsg = 'Expected STASH code .* {!r}'.format(test_val)
with self.assertRaisesRegexp(ValueError, exp_emsg):
test_val == iris.fileformats.pp.STASH(1, 2, 3)(give or take - I haven't tested this code!)
There are two changes here:
- I've removed the indented
self.assertEqualand replaced it with a pure Python equality check - I've replaced
self.assertRaiseswith the preferred (and more robust)self.assertRaisesRegexpand added the expected regular expression failure. This tests that the right error has been raised, and that this test isn't throwing a false positive failure.
|
Ah - the tests have actually failed now rather than erroring and it looks like there are a couple of failing tests that need to be addressed before this can be merged... |
… fix failing tests
|
Thanks for the review @dkillick, all the tests are passing now :) |
|
@ehogan good stuff 👍 I just need to check your most recent changes and we need to get you added to the contributors list, but neither of those things should be too arduous! |
|
Are we sure we want to lose handling cases such as |
Relax regex to allow varying lengths and reinstate tests
|
Thanks for the PR @djkirkham :) However, a lot of tests are failing :( (I'm not sure they're related to the changes in this branch though?) |
Attempts to fix #2624.
However, some of the
test_pp_cf.pytests fail because the test files (located here) now have invalid STASH codes;002000000000.44.101.131200.1920.09.01.00.00.b.ppand008000000000.44.101.000128.1890.09.01.00.00.b.pphave a STASH code of44101(ValueError: Expected STASH code MSI string "mXXsXXiXXX", got u'm??s44i101') andst0fc942.b.ppandst0fc699.b.pphave a STASH code of0(ValueError: Expected STASH code MSI string "mXXsXXiXXX", got u'm02s00i???')Would it be possible for someone to help? What should I do now?