Conversation
- converted tests for read - converted tests for seek - converted tests for write
UnitTest to pytest. For discussion, see #41UnitTest to pytest.
UnitTest to pytest.this simplifies the fixture setup some. A lot less repetition now.
|
50fc1b8 improves the fixtures quite a bit. I took some inspiration from other tests I have seen and used long function names instead of docstrings. I'm not sure I like it. But at least it makes the function names somewhat less redundant--before, they said kind of the same thing as the docstrings. What do you think? |
now symmetric with test_w
There are some peculiarities with how to set the file format when the file is in rw mode. Now, file format is optional for rw mode.
|
The test rewrite is almost complete now. Turns out, Also, Another interesting thing: Opening a file in |
|
OK, the test rewrite is complete now. Please review the changed tests, then we can begin implementing new tests. |
This should have been part of the last commit.
|
The tests are slightly longer now, but they cover a lot more ground, too. In particular, all functionality is tested for filename-opening, filehandle-opening and stream-opening. Total test runtime is about equal to before. I think that the tests themselves look much nicer now, although the fixture setup code is quite hairy. Test coverage is 83% at this point (according to pytest-cov) |
|
The tests look great, I like the py.test style much more than that of the unittest module! I did some clean-up, but one function is still too long to fit into a line: |
|
Thank you! Yeah, that function is ridiculous. I don't think we should change it though, since the name contains a lot of important information. Since the tests are holding up development in other areas, we should merge soon. Any more comments? If you approve, just merge. |
|
I found one issue with Python 2.7, I would like to try to somewhat change the fixtures and I have a few more comments. But there is one thing I would like to have changed before merging: Probably even 4 frames would be enough: Further, I strongly suggest to use a 32-bit float file instead of a 16-bit PCM file. If you for some reason prefer a PCM file, we should use |
I think a separate issue would be a good idea if it is nothing serious.
That is a very good idea! I'll see to it tonight (unless you do it by then).
Ideally, I'd prefer separate test files for 32-bit floats and 16-bit PCMs in both FLAC and WAV containers. At any rate, 16-bit PCM is the default format everywhere though, so this should be our main concern. 16-bit PCM is what most people will use most of the time. |
Go ahead, I won't commit anything for now. I think it's not really important which format we use for testing, neither is it important that we use more than one. I think that we shouldn't concern ourselves with issues regarding the conversion from floating point to two's complement integers. |
|
AAHH, big error. Don't look at that commit! |
also added regression test for this
|
OK, should be fixed now. Sorry for the push forcing. I hope it didn't cause any grief. Anyway, RAW reading and writing should work correctly now, as should all the other kinds. Also, I added a test to make sure that RAW reading will continue to work in the future. |
thus testing for data permutations
|
Now I'm starting to understand the problem!
I think it would be great if we could distinguish the two cases. Because after your changes, if the file already exists, the specified sample rate, channels and format are just silently ignored! BTW, the check with "RAW files must specify a subtype" seems strange, because before this case was handled automatically (in |
I know, but the error message was pretty unclear and didn't match the messages for a missing |
It would be great to be able to detect whether a file exists before we try to open it. This should be done in a new issue though. |
|
Anyway, I converted all the test files to contain meaningful data similar to your suggestion. I did not convert every read to integer though. Instead, I converted every I know this is not an ideal solution, but I chose this route as it was less likely to introduce errors. We can try converting everything to integer in a later issue. Any comments? |
|
I think it would be better if you postpone the whole change to
But that's exactly what I hoped to avoid. It would be probably easier to use 32-bit float files, where you can store exactly 0.5 and compare it exactly to 0.5. It probably wouldn't change anything in the reliability of the tests, but it would lead to simpler and more beautiful test code. I think values like OTOH, if you insist on using PCM_16, you should make a test file with small values, like |
|
All of that is nice, and we really should talk about all of this. But the point of this PR was to create a working test bench. This goal has been achieved. The tests might not be perfect yet, but they test the right things. The tested code might not be perfect yet, but it provably does the right thing. That was the point of this. Now let's merge, and then refactor stuff to our heart's content with the security of a working test bench. This has stalled development long enough. |
|
IMHO, there are two things which have to be done before merging:
|
|
Do the first thing, then. But make sure to also test floating point reading and writing, because they are the primary use case. The second thing, no. Refactor the code if you like. I fully admit that it is not perfect. But is is now more correct than it was before AND we now have tests to make sure that it stays correct. Removing that would be wrong. |
|
As I said, we can discuss and change this later no problem. But right now, this issue is blocking other developments, and it is not functionally broken. So let's please merge, and see about a refactor in a separate issue. |
|
OK then, if you can't wait ... but please at least change the I will do my other suggested changes later as separate pull requests. |
Sorry for the mess.
Implement Unit Tests using pytest.
For discussion, see #41 .
This is not complete yet.
So far, this is not quite as big an improvement as I would have liked. In particular, while the parametric fixtures are quite nice, there is a lot of repetition in there that I haven't been able to get rid of.
At least the tests themselves are pretty clean though.
The
writetests suffer from the fact that the files are opened write-only, and thus there is no way to check whether the data was actually written correctly. This can only be done in read-write mode, which is not implemented yet. The tests for read-write-mode would look rather similar to the write-only tests though, and I haven't figured out how to solve that repetition yet.Finally, I have not figured out how to test both the functions and the methods at the same time yet.