Merge lp:~jamesodhunt/python-apt/test-for-size_to_str into lp:~mvo/python-apt/debian-sid-mirrored
| Status: | Needs review |
|---|---|
| Proposed branch: | lp:~jamesodhunt/python-apt/test-for-size_to_str |
| Merge into: | lp:~mvo/python-apt/debian-sid-mirrored |
| Diff against target: |
218 lines (+155/-15) 4 files modified
debian/changelog (+12/-0) python/cache.cc (+1/-1) python/progress.cc (+31/-14) tests/test_apt_pkg.py (+111/-0) |
| To merge this branch: | bzr merge lp:~jamesodhunt/python-apt/test-for-size_to_str |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Michael Vogt | 2012-10-02 | Needs Information on 2012-10-02 | |
|
Review via email:
|
|||
Description of the Change
* python/progress.cc:
- setattr(): Check return from Py_BuildValue().
- PyFetchProgress
* tests/test_
size_to_str() method.
| Michael Vogt (mvo) wrote : | # |
One more thing, returning "false" from PyFetchProgress
| Barry Warsaw (barry) wrote : | # |
A few additional comments. To fix bug 1030278 (sorry about crossing signals on that one!) I added a test specifically for that bug, which of course fails without the patch. I think I called it test_lp1030278.py modeled after another LP bug test.
I would suggest moving that into test_apt_pkg.py. Maybe you can combine that with grabbing my patch for the bug (only applied to the ubuntu package) and combining it with this merge proposal?
| Barry Warsaw (barry) wrote : | # |
Note that if you wanted to be strict about it (generally not a bad idea when dealing with the Python C API), setattr() in progress.cc should really be checking the return value of Py_BuildValue() too; if that returns NULL, then setattr() should return 0 before calling PyObject_
As for checking the return value of setattr(), that's probably a good idea to do. The alternative is to be optimistic, don't check the return values, and then do a blanket check of PyErr_Occurred() to see if any of them failed. In some sense, it's not as safe, but practically speaking it's probably good enough, especially since if any of them fail, you're probably in trouble. It's probably not a good idea to just let exceptions pass unchecked - that was one of the fundamental problems with LP: #1030278.
| Michael Vogt (mvo) wrote : | # |
On Tue, Oct 02, 2012 at 02:20:24PM -0000, Barry Warsaw wrote:
> A few additional comments. To fix bug 1030278 (sorry about crossing signals on that one!) I added a test specifically for that bug, which of course fails without the patch. I think I called it test_lp1030278.py modeled after another LP bug test.
>
> I would suggest moving that into test_apt_pkg.py. Maybe you can combine that with grabbing my patch for the bug (only applied to the ubuntu package) and combining it with this merge proposal?
Thanks for this suggestion, I had a similar thought :)
I merge them into the debian-sid branch now and put them there as
"test_size_
Thanks!
Michael
Unmerged revisions
- 620. By James Hunt on 2012-10-02
-
tests/test_
apt_pkg. py: New test, currently only for
size_to_str() method. - 619. By James Hunt on 2012-10-02
-
* python/progress.cc:
- setattr(): Check return from Py_BuildValue().
- PyFetchProgress:Pulse( ): Check return from setattr(). - 618. By James Hunt on 2012-10-01
-
python/cache.cc: PkgCacheGetIsMu
ltiArch( ): Return calculated
value rather than a random one.

Hi, thanks for your branch. Its great to see test improvements/code fixes!
I have some questions:
- setattr() is used a bunch of times with no checking of the return value - should it be checked there as well?
- under what circumstances can setattr() fail, i.e. is this branch a result of a specific bug?
Its great that the test is added, it seems to be unreleated to the changes for PyFetchProgress ::Pulse( ) and its also currently working even without the pulse changes. Is it addressing a specific bug? Or just there to have better test coverage (which is welcome of course :)
As for the test itself, a bit of nitpicking: for_string( ), test_from_data(), test_raises_ on_none( )
- the name "data" in test_apt_pkg.py could probably be something more meaningful for the time when more tests get added.
- I would slightly prefer to have a SizeToStrTestCase() and multiple methods like test_raises_
Sorry for the relatively long review, I went through the code-review school of launchpad recently ;) Happy to talk to you about any of the points I mentioned or help with resolving them.
Thanks,
Michael