GNOME Bugzilla – Bug 761834
Patches to port mock to Python 3 and PyGI
Last modified: 2016-04-06 08:45:04 UTC
I am going to use libsecret's Secret Service mock implementation for testing my own SecretStorage library, so I have ported it to Python 3 and modern PyGI API. Please find the patches attached. I also simplified the code a bit by using bytestrings wherever possible — Python 3 has a much nicer bytes API than Python 2.
Created attachment 320811 [details] [review] [PATCH 1/3] mock: Port to modern pygobject API
Created attachment 320812 [details] [review] [PATCH 2/3] mock: Port to Python 3
Created attachment 320813 [details] [review] [PATCH 3/3] mock: Remove unused code And a bonus patch: I removed unused functions, variables and imports throughout the code.
Nice. This looks good to me. Merged into master.
Hm, so we do have a lot of files now which have #!/usr/bin/env python or #!/usr/bin/python i.e. requires python2 and we have libsecret/mock-service.c: "python3", (gchar *)mock_script, ie. requires python3. So now we need to have both installed to run the test suite. That seems unfortunate.
I get this test suite failure (on Debian sid) if only python3-gi and python3-dbus is installed: PASS: test-collection 27 /collection/search-secrets-async Traceback (most recent call last):
+ Trace 236146
sys.exit(main(sys.argv))
module = imp.load_source(name, args.module[0])
from gi.repository import MockService as Mock
ERROR: libsecret/test-py-lookup.py process failed: 1 Traceback (most recent call last): File "./build/tap-unittest", line 84, in <module> sys.exit(main(sys.argv)) File "./build/tap-unittest", line 77, in main module = imp.load_source(name, args.module[0]) File "./libsecret/test-py-clear.py", line 17, in <module> from gi.repository import MockService as Mock ImportError: No module named gi.repository ERROR: libsecret/test-py-clear.py process failed: 1 Traceback (most recent call last): File "./build/tap-unittest", line 84, in <module> sys.exit(main(sys.argv)) File "./build/tap-unittest", line 77, in main module = imp.load_source(name, args.module[0]) File "./libsecret/test-py-store.py", line 16, in <module> from gi.repository import MockService as Mock ImportError: No module named gi.repository ERROR: libsecret/test-py-store.py process failed: 1
Michael, I have just submitted a patch to port the remaining code to Python 3 to bug 687637.