Merge lp:~pitti/aptdaemon/pygobject-fixes into lp:aptdaemon
| Status: | Merged |
|---|---|
| Merged at revision: | 871 |
| Proposed branch: | lp:~pitti/aptdaemon/pygobject-fixes |
| Merge into: | lp:aptdaemon |
| Diff against target: |
68 lines (+13/-26) 2 files modified
aptdaemon/client.py (+11/-26) tests/test_client.py (+2/-0) |
| To merge this branch: | bzr merge lp:~pitti/aptdaemon/pygobject-fixes |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Michael Vogt | 2012-11-19 | Approve on 2012-11-26 | |
| Martin Pitt (community) | Resubmit on 2012-11-26 | ||
|
Review via email:
|
|||
Description of the Change
This makes aptdaemon work with both PyGObject 3.7.2 as well as older versions (tested 3.4.2). See bug 1080736 for details.
- 867. By Martin Pitt on 2012-11-26
-
Add test for TID caching
aptdaemon.client has some metaclass magic to cache transactions with the same
transaction ID. Add a test case that this works properly.Suggested by Michael Vogt and spotted in
https://code.launchpad .net/~pitti/ aptdaemon/ pygobject- fixes/+ merge/134942
| Martin Pitt (pitti) wrote : | # |
Indeed, thanks for this! I committed this test case to trunk already, as it's independent from this proposed change:
http://
| Martin Pitt (pitti) wrote : | # |
Right, so I misunderstood what this is supposed to do. This is supposed to intercept a constructor call, not a method call on an already constructed Transaction object (which is why this first approach doesn't work).
| Martin Pitt (pitti) wrote : | # |
The new patch overrides __new__() which is the place to do changes in object creation. This satisfies the new test case for verifying the caching as well.
One thing that needs to be investigated with this is this failure:
=======
FAIL: test_replace (tests.
Test replacing the current configuration file.
-------
Traceback (most recent call last):
File "/home/
"#Just another config file.\n")
AssertionError: 'BliBlaBlub' != '#Just another config file.\n'
"'BliBlaBlub' != '#Just another config file.\\n'" = '%s != %s' % (safe_repr(
"'BliBlaBlub' != '#Just another config file.\\n'" = self._formatMes
>> raise self.failureExc
I did not get this without the patch, but this looks totally unrelated to transaction caching, and perhaps might be a race condition?
- 868. By Michael Vogt on 2012-11-26
-
tests/test_pk.py: fix long keyid test
- 869. By Michael Vogt on 2012-11-26
-
setup.py: add workaround for nose failure
- 870. By Michael Vogt on 2012-11-26
-
tests/test_pk.py: *cough* typo *cough*
| Michael Vogt (mvo) wrote : | # |
Thanks for your update.
It appears the caching is now working but a bit too agressive, here is a testcase that fails with the branch:
def test_tid_
trans = aptdaemon.
trans2 = aptdaemon.
The problem appears to be that the first arg of "__new__" is the class, not the instance, so the cache will
only ever have one entry AFAICT.
| Martin Pitt (pitti) wrote : | # |
Argh, of course! Thanks for spotting. Fixed now. Now this works fine with python2 + pygi 3.4, python3 + pygi 3.4, and python3 + pygi 3.7.2.
- 871. By Martin Pitt on 2012-11-26
-
Drop MemoizedTransaction mixin.
This uses internal implementation details of PyGObject (GObject.
GObjectMeta)
which stopped working with PyGObject 3.7.2. Replace it with overriding __new__
which does the caching.Extend ClientTest.
test_tid_ caching to ensure that different TIDs actually
generate different transactions.

AFAICT this is not exactly what we want. The __call__ override in the metaclass is called everytime that a new AptTransaction() is created and it will return the transaction from the cache if its there already. This will
only work for metaclasses AFAICT.
With the branch this appears to be no longer working, i.e. the following testcase illustrates it: test_client. py' client. py 2012-08-28 10:50:54 +0000 client. py 2012-11-22 15:42:12 +0000
self. assertEqual( deferred. result. value.code,
aptdaemon. enums.ERROR_ DEP_RESOLUTION_ FAILED)
$ bzr diff
=== modified file 'tests/
--- tests/test_
+++ tests/test_
@@ -110,6 +110,11 @@
+ def test_tid(self): client. AptTransaction( tid, None) client. AptTransaction( tid, None) l(trans, trans2)
+ tid = "/meep"
+ trans = aptdaemon.
+ trans2 = aptdaemon.
+ self.assertEqua
if __name__ == "__main__":
This will work in trunk but fail in this branch. The test should probably be added to the branch just to ensure the behavior stays consistent.