After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 761834 - Patches to port mock to Python 3 and PyGI
Patches to port mock to Python 3 and PyGI
Status: RESOLVED FIXED
Product: libsecret
Classification: Other
Component: General
0.18.x
Other Linux
: Normal normal
: ---
Assigned To: libsecret maintainer(s)
libsecret maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2016-02-10 17:33 UTC by Dmitry Shachnev
Modified: 2016-04-06 08:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[PATCH 1/3] mock: Port to modern pygobject API (1.30 KB, patch)
2016-02-10 17:35 UTC, Dmitry Shachnev
none Details | Review
[PATCH 2/3] mock: Port to Python 3 (12.67 KB, patch)
2016-02-10 17:35 UTC, Dmitry Shachnev
none Details | Review
[PATCH 3/3] mock: Remove unused code (4.25 KB, patch)
2016-02-10 17:36 UTC, Dmitry Shachnev
none Details | Review

Description Dmitry Shachnev 2016-02-10 17:33:08 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.
Comment 1 Dmitry Shachnev 2016-02-10 17:35:05 UTC
Created attachment 320811 [details] [review]
[PATCH 1/3] mock: Port to modern pygobject API
Comment 2 Dmitry Shachnev 2016-02-10 17:35:45 UTC
Created attachment 320812 [details] [review]
[PATCH 2/3] mock: Port to Python 3
Comment 3 Dmitry Shachnev 2016-02-10 17:36:49 UTC
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.
Comment 4 Stef Walter 2016-02-14 17:01:50 UTC
Nice. This looks good to me. Merged into master.
Comment 5 Michael Biebl 2016-04-06 00:17:31 UTC
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.
Comment 6 Michael Biebl 2016-04-06 00:29:58 UTC
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):
  • 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-lookup.py", line 16 in <module>
    from gi.repository import MockService as Mock
ImportError: No module named gi.repository
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
Comment 7 Dmitry Shachnev 2016-04-06 08:45:04 UTC
Michael, I have just submitted a patch to port the remaining code to Python 3 to bug 687637.