Repository navigation
Conversation
|
Table formatting is yet to be tested. Working on that. |
|
I think some unrelated changes (commits) made it into this PR. Could you clean them up (remove them) so it only contains the "new" changes? |
|
Oh. My bad. Sorry. Those commits will make the builds fail. Fixing. Edit: @MSeifert04 Done |
|
|
||
| @pytest.mark.parametrize('test_file', [ | ||
| ('test0.fits'), | ||
| pytest.mark.xfail(('random.fits'), reason = 'bad file') |
There was a problem hiding this comment.
Why create a test just to xfail it? Or am I misunderstand this line?
There was a problem hiding this comment.
There are two tests, one is supposed to pass i.e. test0.fits does exist and other xfails. I thought I should check if providing only one arg works correctly.
There was a problem hiding this comment.
But a test that should fail shouldn't be xfail but tested with pytest.raises?
There was a problem hiding this comment.
I agree with @MSeifert04. xfail shouldn't be used for this case, if a failure is expected and normal behaviour then it should be caught with pytest.raises.
There was a problem hiding this comment.
@MSeifert04 @bsipocz All right. What are the use cases for xfail then?
There was a problem hiding this comment.
xfail- should work but currently doesn't because of some unfixed bug (either in-package or upstream).skip- doesn't work if dependency is too old or if dependency is not installedpytest.raises- should fail, make sure it fails with the right exception (and exception message).
That's not official, that's just how I interpret these.
| # Different test because stderr will not be none in case of testing by existing keyword | ||
| # fitsheader searches for a keyword in all the HDU's | ||
| @pytest.mark.parametrize('test_kw', [ | ||
| ('RANDOMKEY') |
There was a problem hiding this comment.
This looks like only one test? It doesn't make sense to actually parametrize the test, right?
| # with open(request.params[0]) as test_fits: | ||
| # yield test_fits | ||
|
|
||
| @pytest.fixture(scope='module') |
There was a problem hiding this comment.
Is it actually necessary to declare this helper-function as fixture?
There was a problem hiding this comment.
Using fixture I wouldn't have to call the function everytime. (lesser executions because module scope? lots of method use it).
There was a problem hiding this comment.
So this is just so the regex doesn't need to be compiled multiple times?
There was a problem hiding this comment.
Yes. module scope fixtures distribute the return value across functions which need it, don't they? Although I know it's almost no overhead. Should I remove it and replace by functions?
There was a problem hiding this comment.
Well they seem like a really complicated way (using regex) of testing if str.startswith('WARNING') or 'WARNING' in str, right?
There was a problem hiding this comment.
I just thought RE might be of use later. I'll change it if required.
There was a problem hiding this comment.
I agree with @MSeifert04 . This seems unnecessarily complicated. Using startswith() is more readable.
|
It's my personal opinion but I wouldn't test any expected failures, like specifying a non-existing file, keyword or extensions. I think we basically need to make sure the script works and doesn't get accidentally broken. The failures (probably) come from the non-scripty part of the |
|
Doesn't script not emitting warnings when it should come under accidentally broken (i.e. bad user inputs and things)? |
|
@mohanagr Before you push anything else: I would be very interested to see what travis+coverage reports. I really need to think a bit more about the scope of the PR and what to test with scripts. In the end some utility that can be used to test scripts would be really nice. Something like you basically did with your Let's wait and see what the others say. |
|
All right. I'd really like to contribute more to this issue and the testing part in general. Guess that'd help me slowly understand the codebase better, so that I can tackle other issues as well. |
|
@MSeifert04 I got your point. The cases for invalid files, extensions etc. has been handled in the non-script part of the script! I'll remove the |
pllim
left a comment
There was a problem hiding this comment.
I wonder if testing command line need to be this detailed. The command line is basically a short cut to codes that are already tested elsewhere. IMHO, just testing that the command line arguments work as intended for the most common cases is enough; there is no need for all the xfail and raises, no?
| # with open(request.params[0]) as test_fits: | ||
| # yield test_fits | ||
|
|
||
| @pytest.fixture(scope='module') |
There was a problem hiding this comment.
I agree with @MSeifert04 . This seems unnecessarily complicated. Using startswith() is more readable.
|
|
||
| @pytest.mark.parametrize('test_kw,expected', [ | ||
| ('BSCALE', 'BSCALE = 1.000000E0 / REAL = TAPE*BSCALE + BZERO'), | ||
| pytest.mark.xfail(('LRFWAVE', 'LRFWAVE = 0.0 / linear ramp filter wavelength'), reason = 'bad format') |
There was a problem hiding this comment.
Putting xfail inside parametrize is hard to read. I prefer xfail to be its own thing.
| class TestFITSheader_script(FitsTestCase): | ||
|
|
||
| def setup_method(self, method): | ||
| self.sys_argv_orig = sys.argv |
There was a problem hiding this comment.
Using subprocess to spawn the command line would be simpler but I wonder if that would work in Windows; do you know, @MSeifert04 ?
There was a problem hiding this comment.
There should be no problem with subprocess, I've used it several times (mostly to call zlib). However, is coverage able to deal with subprocesses?
There was a problem hiding this comment.
Good point. Maybe this is not worth pursuing.
There was a problem hiding this comment.
@pllim subprocess does work on windows AFAIK. Also I will remove the xfail things. I understand the usage better now. I will add the test for the table formatting and go on with fitscheck.
|
It is possible to avoid mocking About the way to test scripts, some options:
Just some thoughts, I'm not sure it's useful to put too much work here. |
|
For the sake of simplicity, I think the current call to |
|
@pllim Sorry I read your comment after pushing. I have taken other comments into account.
|
|
@mohanagr Just out of interest: What is the motivation for the tests you created? Did you create tests based on (missing) coverage? Or because of use-cases you had? This is not meant as criticism, I'm just curious 😅 |
|
@MSeifert04 Not really. But are you talking about coverage in this particular file? Edit :- I am fairly new to testing and actually wrote the tests based on the usecases I could understand. |
|
Also can you suggest how to test |
|
Can someone please tell me how to go ahead with #5874 ? Should I push the fix here? Because it will hamper the testing (one of the usecases of the |
|
Ideally, the bug fix would be a separate PR and should be merged first, and then this PR to be rebased on top of that once merged. They have to be separate because this PR would go into v2.0 and the bug fix into v1.3.2. Hope this clarifies the matter. I apologize for any inconvenience caused. |
|
@pllim Yes. Thanks. I'll just file a separate PR too. I pushed here so that I could continue testing this. Or I'll to omit one test case. |
|
@mohanagr , the affected test can move to the new bug fix PR as well, if possible. This is because usually we ask the bug fix PR to add a test to demonstrate that the bug is indeed fixed and to prevent it from creeping back in the future. |
833fc3e to
6c61675
Compare
|
@mohanagr - Are you still interested in this ? If yes, to make progress, I would suggest to focus here on |
|
Yes, I'll continue this and try to fix the test scripts.
On May 15, 2017 3:43 PM, "Simon Conseil" <[email protected]> wrote:
@mohanagr <https://github.com/mohanagr> - Are you still interested in this
? If yes, to make progress, I would suggest to focus here on
test_fitsheader.py, and to limit the number of things to test.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#5858 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AOc7f9pA6cCfWYWUvBbn0JOjiqi3EN7uks5r6CVIgaJpZM4MSdgI>
.
|
|
@mohanagr - Ok, great. So I think you should start with testing the normal usage of the script: choose a test file and simply test that the output is the expected one (with or without |
| from ..hdu import PrimaryHDU | ||
| from ..scripts import fitsheader | ||
| from ....tests.helper import catch_warnings | ||
| from ....tests.helper import pytest |
There was a problem hiding this comment.
Could you rebase on master, and import pytest directly (the bundle version was removed recently).
| import re | ||
|
|
||
| from . import FitsTestCase | ||
| from ..hdu import PrimaryHDU |
There was a problem hiding this comment.
Please remove the imports that are not used (PrimaryHDU, AstropyDeprecationWarning).
|
Hi humans 👋 - this pull request hasn't had any new commits for approximately 6 months. I plan to close this in a month if the pull request doesn't have any new commits by then. In lieu of a stalled pull request, please close this and open an issue instead to revisit in the future. Maintainers may also choose to add If you believe I commented on this issue incorrectly, please report this here. |
|
This was created during GSoC 2017 application period, which is now over. @mohanagr , if you are interested to finish this, feel free to re-open, but I am closing this for now due to inactivity. |
Implements test for script
fitsheaderas of now.Reference:
Issue #5799