Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-xcffib for openSUSE:Factory checked in at 2022-10-01 17:42:13 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-xcffib (Old) and /work/SRC/openSUSE:Factory/.python-xcffib.new.2275 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-xcffib" Sat Oct 1 17:42:13 2022 rev:11 rq:1006504 version:0.12.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-xcffib/python-xcffib.changes 2021-07-16 22:13:19.378583950 +0200 +++ /work/SRC/openSUSE:Factory/.python-xcffib.new.2275/python-xcffib.changes 2022-10-01 17:42:19.945580059 +0200 @@ -1,0 +2,9 @@ +Tue Sep 27 16:04:01 UTC 2022 - Mark??ta Machov?? <mmach...@suse.com> + +- Update to 0.12.1 + * Replace nose by pytest + * Allow the master xcb version to pass even if failing + * drop Python 3.6, support Python 3.10 + * ci: test with new xcb 1.15 release + +------------------------------------------------------------------- Old: ---- xcffib-0.11.1.tar.gz New: ---- xcffib-0.12.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-xcffib.spec ++++++ --- /var/tmp/diff_new_pack.IJCECH/_old 2022-10-01 17:42:20.441580963 +0200 +++ /var/tmp/diff_new_pack.IJCECH/_new 2022-10-01 17:42:20.445580970 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-xcffib # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,7 +19,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 Name: python-xcffib -Version: 0.11.1 +Version: 0.12.1 Release: 0 Summary: A drop in replacement for xpyb, an XCB python binding License: Apache-2.0 ++++++ xcffib-0.11.1.tar.gz -> xcffib-0.12.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xcffib-0.11.1/MANIFEST.in new/xcffib-0.12.1/MANIFEST.in --- old/xcffib-0.11.1/MANIFEST.in 2020-07-21 14:59:17.000000000 +0200 +++ new/xcffib-0.12.1/MANIFEST.in 2022-09-25 16:38:17.000000000 +0200 @@ -2,3 +2,4 @@ include LICENSE exclude xcffib/_ffi.py include test/__init__.py +include test/conftest.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xcffib-0.11.1/PKG-INFO new/xcffib-0.12.1/PKG-INFO --- old/xcffib-0.11.1/PKG-INFO 2020-11-29 16:55:27.120034700 +0100 +++ new/xcffib-0.12.1/PKG-INFO 2022-09-25 16:44:40.079757000 +0200 @@ -1,12 +1,11 @@ -Metadata-Version: 1.1 +Metadata-Version: 2.1 Name: xcffib -Version: 0.11.1 +Version: 0.12.1 Summary: A drop in replacement for xpyb, an XCB python binding Home-page: http://github.com/tych0/xcffib Author: Tycho Andersen Author-email: tycho@tycho.pizza License: Apache License 2.0 -Description: UNKNOWN Keywords: xcb xpyb cffi x11 x windows Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable @@ -19,3 +18,7 @@ Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Topic :: Software Development :: Libraries +License-File: LICENSE + +UNKNOWN + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xcffib-0.11.1/README.md new/xcffib-0.12.1/README.md --- old/xcffib-0.11.1/README.md 2020-11-18 03:22:53.000000000 +0100 +++ new/xcffib-0.12.1/README.md 2022-05-03 23:36:42.000000000 +0200 @@ -31,7 +31,7 @@ expected haskell test data if the tests are failing because you made a change to the generated python code. -## Hacking on new xcb-proto versions +### Hacking on new xcb-proto versions Sometimes (more often recently), xcb-proto makes some updates that we need to do some work for. These often require some updates to `xcb-types` as well. @@ -45,6 +45,15 @@ make XCBDIR=~/packages/xcb-proto/src check +### Hacking on new xcb-types versions + +To go along with new xcb-proto elements, sometimes you need to hack on newer +versions of xcb-types. Newer cabals require you to do something like: + + echo packages: ../xcb-types/xcb-types.cabal ./xcffib.cabal > cabal.project + +In order to find locally modified versions of xcb-types. + ## Differences In general, you should `s/xcb/xcffib/g`. Explicit differences are listed below, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xcffib-0.11.1/setup.py new/xcffib-0.12.1/setup.py --- old/xcffib-0.11.1/setup.py 2020-11-29 16:55:26.000000000 +0100 +++ new/xcffib-0.12.1/setup.py 2022-09-25 16:44:39.000000000 +0200 @@ -54,7 +54,7 @@ cffi_modules=["xcffib/ffi_build.py:ffi"] ) -version = "0.11.1" +version = "0.12.1" dependencies = ['six', requires_cffi] setup( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xcffib-0.11.1/test/conftest.py new/xcffib-0.12.1/test/conftest.py --- old/xcffib-0.11.1/test/conftest.py 1970-01-01 01:00:00.000000000 +0100 +++ new/xcffib-0.12.1/test/conftest.py 2022-07-03 23:42:33.000000000 +0200 @@ -0,0 +1,84 @@ +# Copyright 2014 Tycho Andersen +# Copyright 2021 Sean Vig +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import xcffib +from xcffib.testing import XvfbTest +from xcffib.xproto import EventMask + +import pytest + + +@pytest.fixture +def xcffib_test(): + with XcffibTest() as test_data: + yield test_data + + +@pytest.fixture +def xproto_test(xcffib_test): + xcffib_test.xproto = xcffib.xproto.xprotoExtension(xcffib_test.conn) + return xcffib_test + + +class XcffibTest(XvfbTest): + """ A home for common functions needed for xcffib testing. """ + + def setUp(self): + XvfbTest.setUp(self) + self.xproto = xcffib.xproto.xprotoExtension(self.conn) + + def tearDown(self): + self.xproto = None + XvfbTest.tearDown(self) + + @property + def default_screen(self): + return self.conn.setup.roots[self.conn.pref_screen] + + def create_window(self, wid=None, x=0, y=0, w=1, h=1, is_checked=False): + if wid is None: + wid = self.conn.generate_id() + return self.xproto.CreateWindow( + self.default_screen.root_depth, + wid, + self.default_screen.root, + x, y, w, h, + 0, + xcffib.xproto.WindowClass.InputOutput, + self.default_screen.root_visual, + xcffib.xproto.CW.BackPixel | xcffib.xproto.CW.EventMask, + [ + self.default_screen.black_pixel, + xcffib.xproto.EventMask.StructureNotify + ], + is_checked=is_checked + ) + + def xeyes(self): + # Enable CreateNotify + self.xproto.ChangeWindowAttributesChecked( + self.default_screen.root, + xcffib.xproto.CW.EventMask, + [ + EventMask.SubstructureNotify | + EventMask.StructureNotify | + EventMask.SubstructureRedirect + ] + ).check() + + self.spawn(['xeyes']) + + def intern(self, name): + return self.xproto.InternAtom(False, len(name), name).reply().atom diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xcffib-0.11.1/test/test_connection.py new/xcffib-0.12.1/test/test_connection.py --- old/xcffib-0.11.1/test/test_connection.py 2020-11-18 03:07:13.000000000 +0100 +++ new/xcffib-0.12.1/test/test_connection.py 2022-07-03 23:42:33.000000000 +0200 @@ -19,62 +19,64 @@ import xcffib.xproto from xcffib import ffi -from xcffib.testing import XvfbTest -from .testing import XcffibTest -import struct +import pytest -class TestConnection(XcffibTest): - def setUp(self): - XvfbTest.setUp(self) - self.xproto = xcffib.xproto.xprotoExtension(self.conn) - - def tearDown(self): - self.xproto = None - XvfbTest.tearDown(self) - - def test_invalid_display(self): - try: - self.conn = xcffib.Connection('notvalid') - self.conn.invalid() - except xcffib.ConnectionException: - pass - else: - raise Exception("no connection exception!") +class TestConnection: + def test_invalid_display(self, xproto_test): + with pytest.raises(xcffib.ConnectionException): + xproto_test.conn = xcffib.Connection("notvalid") - def test_get_setup(self): - setup = self.conn.get_setup() + def test_get_setup(self, xproto_test): + setup = xproto_test.conn.get_setup() # When X upgrades, we can probably manage to change this test :-) assert setup.protocol_major_version == 11 assert setup.protocol_minor_version == 0 - def test_get_screen_pointers(self): - screens = self.conn.get_screen_pointers() + def test_get_screen_pointers(self, xproto_test): + screens = xproto_test.conn.get_screen_pointers() assert len(screens) == 1 screen = screens[0] assert ffi.typeof(screen) is ffi.typeof("xcb_screen_t *") - assert screen.root == self.default_screen.root - assert screen.width_in_pixels == self.width - assert screen.height_in_pixels == self.height - assert screen.root_depth == self.depth + assert screen.root == xproto_test.default_screen.root + assert screen.width_in_pixels == xproto_test.width + assert screen.height_in_pixels == xproto_test.height + assert screen.root_depth == xproto_test.depth + + def test_seq_increases(self, xproto_test): + # If this test starts failing because the sequence numbers don't mach, + # that's probably because you added a new test that imports a new X + # extension. When that happens, every new connection automatically does + # a QueryExtention for each new ext that has been imported, so the + # squence numbers go up by one. + # + # i.e: + # xproto setup query = seqno 0 + # xtest setup query = seqno 1 + assert xproto_test.xproto.GetInputFocus().sequence == 2 + assert xproto_test.xproto.GetInputFocus().sequence == 3 - def test_discard_sequence(self): - cookie = self.xproto.GetInputFocus() + def test_discard_sequence(self, xproto_test): + cookie = xproto_test.xproto.GetInputFocus() cookie.discard_reply() # this hangs if you leave it in, because the reply really was discarded # assert cookie.reply() - def test_list_extensions(self): - reply = self.conn.core.ListExtensions().reply() + def test_invalid(self, xproto_test): + with pytest.raises(xcffib.ConnectionException): + xcffib.Connection("notadisplay") + + def test_list_extensions(self, xproto_test): + reply = xproto_test.conn.core.ListExtensions().reply() exts = [ext.name.to_string() for ext in reply.names] assert "XVideo" in exts - def test_create_window(self): - wid = self.conn.generate_id() - cookie = self.create_window(wid=wid) + def test_create_window(self, xproto_test): + wid = xproto_test.conn.generate_id() + cookie = xproto_test.create_window(wid=wid) - cookie = self.xproto.GetGeometry(wid) + cookie = xproto_test.xproto.GetGeometry(wid) reply = cookie.reply() assert reply.x == 0 @@ -82,120 +84,123 @@ assert reply.width == 1 assert reply.height == 1 - def test_wait_for_nonexistent_request(self): - try: - self.conn.wait_for_reply(10) - except xcffib.XcffibException: - pass - else: - raise Exception("xcffib exception expected") + def test_wait_for_nonexistent_request(self, xproto_test): + with pytest.raises(xcffib.XcffibException): + xproto_test.conn.wait_for_reply(10) - def test_no_windows(self): + def test_no_windows(self, xproto_test): # Make sure there aren't any windows in the root window. This mostly # just exists to make sure people aren't somehow mistakenly running a # test in their own X session, which could corrupt results. - reply = self.xproto.QueryTree(self.default_screen.root).reply() + reply = xproto_test.xproto.QueryTree(xproto_test.default_screen.root).reply() assert reply.children_len == 0 assert len(reply.children) == 0 - def test_create_window_creates_window(self): - wid = self.conn.generate_id() - self.create_window(wid=wid) - reply = self.xproto.QueryTree(self.default_screen.root).reply() + def test_create_window_creates_window(self, xproto_test): + wid = xproto_test.conn.generate_id() + xproto_test.create_window(wid=wid) + reply = xproto_test.xproto.QueryTree(xproto_test.default_screen.root).reply() assert reply.children_len == 1 assert len(reply.children) == 1 assert reply.children[0] == wid - def test_checking_unchecked_fails(self): - try: - wid = self.conn.generate_id() - self.create_window(wid) - self.xproto.QueryTreeUnchecked(self.default_screen.root).check() - except AssertionError: - pass - else: - raise Exception("expected assertion error") - - def test_checking_default_checked_fails(self): - try: - wid = self.conn.generate_id() - self.create_window(wid) - cookie = self.xproto.QueryTree(self.default_screen.root) + def test_checking_unchecked_fails(self, xproto_test): + with pytest.raises(AssertionError): + wid = xproto_test.conn.generate_id() + xproto_test.create_window(wid) + xproto_test.xproto.QueryTreeUnchecked( + xproto_test.default_screen.root + ).check() + + def test_checking_default_checked_fails(self, xproto_test): + with pytest.raises(AssertionError): + wid = xproto_test.conn.generate_id() + xproto_test.create_window(wid) + cookie = xproto_test.xproto.QueryTree(xproto_test.default_screen.root) cookie.check() - except AssertionError: - pass - else: - raise Exception("expected assertion error") - - def test_checking_foreced_checked_succeeds(self): - wid = self.conn.generate_id() - cookie = self.create_window(wid, is_checked=True) + + def test_checking_foreced_checked_succeeds(self, xproto_test): + wid = xproto_test.conn.generate_id() + cookie = xproto_test.create_window(wid, is_checked=True) cookie.check() - def test_create_window_generates_event(self): - self.xeyes() - self.conn.flush() + def test_create_window_generates_event(self, xproto_test): + xproto_test.xeyes() - e = self.conn.wait_for_event() + e = xproto_test.conn.wait_for_event() assert isinstance(e, xcffib.xproto.CreateNotifyEvent) - def test_query_invalid_wid_generates_error(self): - try: + def test_query_invalid_wid_generates_error(self, xproto_test): + with pytest.raises(xcffib.xproto.WindowError): # query a bad WINDOW - self.xproto.QueryTree(0xf00).reply() - except xcffib.xproto.WindowError: - pass - else: - raise Exception("expected WindowError") - - def test_OpenFont(self): - fid = self.conn.generate_id() - self.xproto.OpenFont(fid, len("cursor"), "cursor") - - def test_ConfigureWindow(self): - wid = self.conn.generate_id() - self.create_window(wid=wid) - self.xproto.ConfigureWindowChecked(wid, 0, []).check() - - def test_external_ConfigureWindow(self): - self.xeyes() - self.conn.flush() - - e = self.conn.wait_for_event() - - r = self.xproto.ConfigureWindowChecked(e.window, 0, []).check() - r = self.xproto.DestroyWindowChecked(e.window).check() - - def test_ChangeProperty_WM_NAME(self): - wid = self.conn.generate_id() - self.create_window(wid=wid) + xproto_test.xproto.QueryTree(0xF00).reply() - title = "test" - self.xproto.ChangeProperty(xcffib.xproto.PropMode.Replace, wid, - xcffib.xproto.Atom.WM_NAME, xcffib.xproto.Atom.STRING, 8, - len(title), title) + def test_OpenFont(self, xproto_test): + fid = xproto_test.conn.generate_id() + xproto_test.xproto.OpenFont(fid, len("cursor"), "cursor") + + def test_ConfigureWindow(self, xproto_test): + wid = xproto_test.conn.generate_id() + xproto_test.create_window(wid=wid) + xproto_test.xproto.ConfigureWindowChecked(wid, 0, []).check() + + def test_external_ConfigureWindow(self, xproto_test): + xproto_test.xeyes() + + e = xproto_test.conn.wait_for_event() + + xproto_test.xproto.ConfigureWindowChecked(e.window, 0, []).check() + xproto_test.xproto.DestroyWindowChecked(e.window).check() - reply = self.xproto.GetProperty(False, wid, - xcffib.xproto.Atom.WM_NAME, xcffib.xproto.GetPropertyType.Any, 0, 1).reply() + def test_ChangeProperty_WM_NAME(self, xproto_test): + wid = xproto_test.conn.generate_id() + xproto_test.create_window(wid=wid) + + title = "test" + xproto_test.xproto.ChangeProperty( + xcffib.xproto.PropMode.Replace, + wid, + xcffib.xproto.Atom.WM_NAME, + xcffib.xproto.Atom.STRING, + 8, + len(title), + title, + ) + + reply = xproto_test.xproto.GetProperty( + False, + wid, + xcffib.xproto.Atom.WM_NAME, + xcffib.xproto.GetPropertyType.Any, + 0, + 1, + ).reply() assert reply.value.to_string() == title - def test_ChangeProperty_NET_WM_NAME(self): - wid = self.conn.generate_id() - self.create_window(wid=wid) + def test_ChangeProperty_NET_WM_NAME(self, xproto_test): + wid = xproto_test.conn.generate_id() + xproto_test.create_window(wid=wid) - net_wm_name = self.intern("_NET_WM_NAME") - utf8_string = self.intern("UTF8_STRING") + net_wm_name = xproto_test.intern("_NET_WM_NAME") + utf8_string = xproto_test.intern("UTF8_STRING") title_bytes = b"test\xc2\xb7" title_string = six.u("test\u00B7") # First check with an object already encoded as bytes - self.xproto.ChangeProperty(xcffib.xproto.PropMode.Replace, wid, - net_wm_name, utf8_string, 8, - len(title_bytes), title_bytes) - - reply = self.xproto.GetProperty(False, wid, - net_wm_name, xcffib.xproto.GetPropertyType.Any, 0, (2 ** 32) - 1).reply() + xproto_test.xproto.ChangeProperty( + xcffib.xproto.PropMode.Replace, + wid, + net_wm_name, + utf8_string, + 8, + len(title_bytes), + title_bytes, + ) + + reply = xproto_test.xproto.GetProperty( + False, wid, net_wm_name, xcffib.xproto.GetPropertyType.Any, 0, (2 ** 32) - 1 + ).reply() print(reply.value.buf()) assert reply.value.buf() == title_bytes @@ -203,106 +208,124 @@ assert reply.value.to_utf8() == title_string # Also check with a unicode string - self.xproto.ChangeProperty(xcffib.xproto.PropMode.Replace, wid, - net_wm_name, utf8_string, 8, - len(title_string.encode('utf-8')), title_string) - - reply = self.xproto.GetProperty(False, wid, - net_wm_name, xcffib.xproto.GetPropertyType.Any, 0, (2 ** 32) - 1).reply() + xproto_test.xproto.ChangeProperty( + xcffib.xproto.PropMode.Replace, + wid, + net_wm_name, + utf8_string, + 8, + len(title_string.encode("utf-8")), + title_string, + ) + + reply = xproto_test.xproto.GetProperty( + False, wid, net_wm_name, xcffib.xproto.GetPropertyType.Any, 0, (2 ** 32) - 1 + ).reply() assert reply.value.buf() == title_bytes assert reply.value.to_utf8() == title_string - def test_ChangeProperty_WM_PROTOCOLS(self): - wid = self.conn.generate_id() - self.create_window(wid=wid) - - wm_protocols = self.intern("WM_PROTOCOLS") - - wm_delete_window = self.intern("WM_DELETE_WINDOW") - - self.xproto.ChangeProperty(xcffib.xproto.PropMode.Replace, wid, - wm_protocols, xcffib.xproto.Atom.ATOM, 32, - 1, (wm_delete_window,)) - # For Python 2 only, make sure packing can handle both ints and longs - if six.PY2: - self.xproto.ChangeProperty(xcffib.xproto.PropMode.Replace, wid, - wm_protocols, xcffib.xproto.Atom.ATOM, 32, - 1, (long(wm_delete_window),)) - - reply = self.xproto.GetProperty(False, wid, wm_protocols, xcffib.xproto.Atom.ATOM, 0, 1).reply() + def test_ChangeProperty_WM_PROTOCOLS(self, xproto_test): + wid = xproto_test.conn.generate_id() + xproto_test.create_window(wid=wid) + + wm_protocols = xproto_test.intern("WM_PROTOCOLS") + + wm_delete_window = xproto_test.intern("WM_DELETE_WINDOW") + + xproto_test.xproto.ChangeProperty( + xcffib.xproto.PropMode.Replace, + wid, + wm_protocols, + xcffib.xproto.Atom.ATOM, + 32, + 1, + (wm_delete_window,), + ) + + reply = xproto_test.xproto.GetProperty( + False, wid, wm_protocols, xcffib.xproto.Atom.ATOM, 0, 1 + ).reply() assert reply.value.to_atoms() == (wm_delete_window,) - wm_take_focus = self.intern("WM_TAKE_FOCUS") - - self.xproto.ChangeProperty(xcffib.xproto.PropMode.Replace, wid, - wm_protocols, xcffib.xproto.Atom.ATOM, 32, - 1, (wm_take_focus,)) + wm_take_focus = xproto_test.intern("WM_TAKE_FOCUS") - reply = self.xproto.GetProperty(False, wid, wm_protocols, xcffib.xproto.Atom.ATOM, 0, 1).reply() + xproto_test.xproto.ChangeProperty( + xcffib.xproto.PropMode.Replace, + wid, + wm_protocols, + xcffib.xproto.Atom.ATOM, + 32, + 1, + (wm_take_focus,), + ) + + reply = xproto_test.xproto.GetProperty( + False, wid, wm_protocols, xcffib.xproto.Atom.ATOM, 0, 1 + ).reply() assert reply.value.to_atoms() == (wm_take_focus,) - def test_GetAtomName(self): + def test_GetAtomName(self, xproto_test): wm_protocols = "WM_PROTOCOLS" - atom = self.intern(wm_protocols) - atom_name = self.xproto.GetAtomName(atom).reply().name + atom = xproto_test.intern(wm_protocols) + atom_name = xproto_test.xproto.GetAtomName(atom).reply().name assert atom_name.to_string() == wm_protocols - def test_KillClient(self): - self.xeyes() - - self.conn.flush() + def test_KillClient(self, xproto_test): + xproto_test.xeyes() - e1 = self.conn.wait_for_event() - self.xproto.KillClient(e1.window) + e1 = xproto_test.conn.wait_for_event() + xproto_test.xproto.KillClient(e1.window) # one is MapRequest and the other is DestroyNotify, they may be in # either order for _ in range(2): - self.conn.flush() - k1 = self.conn.wait_for_event() + xproto_test.conn.flush() + k1 = xproto_test.conn.wait_for_event() if isinstance(k1, xcffib.xproto.DestroyNotifyEvent): assert e1.window == k1.window return assert False, "no DestroyNotifyEvent" - def test_connect(self): + def test_connect(self, xproto_test): c = xcffib.connect() c.invalid() assert c.has_error() == 0 c.disconnect() - def test_auth_connect(self): + def test_auth_connect(self, xproto_test): authname = six.b("MIT-MAGIC-COOKIE-1") - authdata = six.b("\xa5\xcf\x95\xfa\x19\x49\x03\x60\xaf\xe4\x1e\xcd\xa3\xe2\xad\x47") + authdata = six.b( + "\xa5\xcf\x95\xfa\x19\x49\x03\x60\xaf\xe4\x1e\xcd\xa3\xe2\xad\x47" + ) - authstr = authname + six.b(':') + authdata + authstr = authname + six.b(":") + authdata - conn = xcffib.connect(display=os.environ['DISPLAY'], auth=authstr) + conn = xcffib.connect(display=os.environ["DISPLAY"], auth=authstr) assert conn.get_setup().roots[0].root > 0 # This is an adaptation of the test from #27 - def test_build_atom_cache(self): + def test_build_atom_cache(self, xproto_test): # This will hold the forward *and* reverse lookups for any given atom atoms = {} cookies = [] # Batch the replies by creating a list of cookies first: for i in range(1, 10000): - c = self.conn.core.GetAtomName(i) + c = xproto_test.conn.core.GetAtomName(i) cookies.append((i, c)) for i, c in cookies: try: name = c.reply().name.to_string() except xcffib.xproto.BadAtom: continue - atoms.update({i: name}) # Lookup by number - atoms.update({name: i}) # Lookup by name + atoms.update({i: name}) # Lookup by number + atoms.update({name: i}) # Lookup by name - def test_wrap(self): + def test_wrap(self, xproto_test): c = xcffib.connect() c.invalid() c2 = xcffib.wrap(xcffib.ffi.cast("long", c._conn)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xcffib-0.11.1/test/test_crazy_window_script.py new/xcffib-0.12.1/test/test_crazy_window_script.py --- old/xcffib-0.11.1/test/test_crazy_window_script.py 2019-12-29 01:30:22.000000000 +0100 +++ new/xcffib-0.12.1/test/test_crazy_window_script.py 2022-05-03 23:36:42.000000000 +0200 @@ -23,7 +23,6 @@ """ This is mostly stolen from qtile's tests/scripts/window.py """ -from __future__ import print_function import os import sys import struct @@ -31,15 +30,14 @@ import xcffib import xcffib.xproto from xcffib.xproto import EventMask -from xcffib.testing import XvfbTest -class TestWindow(XvfbTest): - def test_the_script(self): +class TestWindow: + def test_the_script(self, xcffib_test): NAME = "one" for i in range(20): try: - conn = xcffib.connect(os.environ['DISPLAY']) + conn = xcffib.connect(os.environ["DISPLAY"]) except xcffib.ConnectionException: time.sleep(0.1) continue @@ -48,51 +46,104 @@ sys.exit(1) break else: - print("Could not open window on display %s" % (sys.argv[1]), file=sys.stderr) + print( + "Could not open window on display %s" % (sys.argv[1]), file=sys.stderr + ) sys.exit(1) screen = conn.get_setup().roots[conn.pref_screen] window = conn.generate_id() - background = conn.core.AllocColor(screen.default_colormap, 0x2828, 0x8383, 0xCECE).reply().pixel # Color "#2883ce" - conn.core.CreateWindow(xcffib.CopyFromParent, window, screen.root, - 100, 100, 100, 100, 1, - xcffib.xproto.WindowClass.InputOutput, screen.root_visual, - xcffib.xproto.CW.BackPixel | xcffib.xproto.CW.EventMask, - [background, xcffib.xproto.EventMask.StructureNotify | xcffib.xproto.EventMask.Exposure]) - - conn.core.ChangeProperty(xcffib.xproto.PropMode.Replace, - window, xcffib.xproto.Atom.WM_NAME, - xcffib.xproto.Atom.STRING, 8, len(NAME), - NAME) + background = ( + conn.core.AllocColor(screen.default_colormap, 0x2828, 0x8383, 0xCECE) + .reply() + .pixel + ) # Color "#2883ce" + conn.core.CreateWindow( + xcffib.CopyFromParent, + window, + screen.root, + 100, + 100, + 100, + 100, + 1, + xcffib.xproto.WindowClass.InputOutput, + screen.root_visual, + xcffib.xproto.CW.BackPixel | xcffib.xproto.CW.EventMask, + [ + background, + xcffib.xproto.EventMask.StructureNotify + | xcffib.xproto.EventMask.Exposure, + ], + ) + + conn.core.ChangeProperty( + xcffib.xproto.PropMode.Replace, + window, + xcffib.xproto.Atom.WM_NAME, + xcffib.xproto.Atom.STRING, + 8, + len(NAME), + NAME, + ) wm_protocols = "WM_PROTOCOLS" - wm_protocols = conn.core.InternAtom(0, len(wm_protocols), wm_protocols).reply().atom + wm_protocols = ( + conn.core.InternAtom(0, len(wm_protocols), wm_protocols).reply().atom + ) wm_delete_window = "WM_DELETE_WINDOW" - wm_delete_window = conn.core.InternAtom(0, len(wm_delete_window), wm_delete_window).reply().atom + wm_delete_window = ( + conn.core.InternAtom(0, len(wm_delete_window), wm_delete_window) + .reply() + .atom + ) - conn.core.ChangeProperty(xcffib.xproto.PropMode.Replace, - window, wm_protocols, - xcffib.xproto.Atom.ATOM, 32, 1, - [wm_delete_window]) - - conn.core.ConfigureWindow(window, - xcffib.xproto.ConfigWindow.X | xcffib.xproto.ConfigWindow.Y | - xcffib.xproto.ConfigWindow.Width | xcffib.xproto.ConfigWindow.Height | - xcffib.xproto.ConfigWindow.BorderWidth, - [0, 0, 100, 100, 1]) + conn.core.ChangeProperty( + xcffib.xproto.PropMode.Replace, + window, + wm_protocols, + xcffib.xproto.Atom.ATOM, + 32, + 1, + [wm_delete_window], + ) + + conn.core.ConfigureWindow( + window, + xcffib.xproto.ConfigWindow.X + | xcffib.xproto.ConfigWindow.Y + | xcffib.xproto.ConfigWindow.Width + | xcffib.xproto.ConfigWindow.Height + | xcffib.xproto.ConfigWindow.BorderWidth, + [0, 0, 100, 100, 1], + ) conn.core.MapWindow(window) conn.flush() - conn.core.ConfigureWindow(window, - xcffib.xproto.ConfigWindow.X | xcffib.xproto.ConfigWindow.Y | - xcffib.xproto.ConfigWindow.Width | xcffib.xproto.ConfigWindow.Height | - xcffib.xproto.ConfigWindow.BorderWidth, - [0, 0, 100, 100, 1]) + conn.core.ConfigureWindow( + window, + xcffib.xproto.ConfigWindow.X + | xcffib.xproto.ConfigWindow.Y + | xcffib.xproto.ConfigWindow.Width + | xcffib.xproto.ConfigWindow.Height + | xcffib.xproto.ConfigWindow.BorderWidth, + [0, 0, 100, 100, 1], + ) # now kill the window from the "wm" side via WM_DELETE_WINDOW protocol - WM_PROTOCOLS = self.conn.core.InternAtom(False, len("WM_PROTOCOLS"), "WM_PROTOCOLS").reply().atom - WM_DELETE_WINDOW = self.conn.core.InternAtom(False, len("WM_DELETE_WINDOW"), "WM_DELETE_WINDOW").reply().atom + WM_PROTOCOLS = ( + xcffib_test.conn.core.InternAtom(False, len("WM_PROTOCOLS"), "WM_PROTOCOLS") + .reply() + .atom + ) + WM_DELETE_WINDOW = ( + xcffib_test.conn.core.InternAtom( + False, len("WM_DELETE_WINDOW"), "WM_DELETE_WINDOW" + ) + .reply() + .atom + ) vals = [ 33, # ClientMessageEvent 32, # Format @@ -105,10 +156,10 @@ 0, 0, ] - e = struct.pack('BBHII5I', *vals) - self.conn.core.SendEvent(False, window, EventMask.NoEvent, e) + e = struct.pack("BBHII5I", *vals) + xcffib_test.conn.core.SendEvent(False, window, EventMask.NoEvent, e) - self.conn.flush() + xcffib_test.conn.flush() while 1: conn.flush() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xcffib-0.11.1/test/test_fakeinput.py new/xcffib-0.12.1/test/test_fakeinput.py --- old/xcffib-0.11.1/test/test_fakeinput.py 2019-12-29 01:30:22.000000000 +0100 +++ new/xcffib-0.12.1/test/test_fakeinput.py 2022-05-03 23:36:42.000000000 +0200 @@ -2,46 +2,45 @@ import xcffib.xproto import xcffib.xtest -from .testing import XcffibTest -class TestConnection(XcffibTest): - def test_fakeinput(self): - xtest = self.conn(xcffib.xtest.key) - - setup = self.conn.get_setup() - screen = setup.roots[0] - def test(x, y): - # motion - xtest.FakeInput( - 6, - 0, - xcffib.xproto.Time.CurrentTime, - screen.root, - x, - y, - 0) - - # press - xtest.FakeInput( - 4, - 1, - xcffib.xproto.Time.CurrentTime, - screen.root, - 0, - 0, - 0) - - # release - xtest.FakeInput( - 5, - 1, - xcffib.xproto.Time.CurrentTime, - screen.root, - 2, - 2, - 0) - self.conn.flush() - test(50, 10) +def test_fakeinput(xcffib_test): + xtest = xcffib_test.conn(xcffib.xtest.key) - # we shouldn't get any errors - self.conn.poll_for_event() + setup = xcffib_test.conn.get_setup() + screen = setup.roots[0] + + def test(x, y): + # motion + xtest.FakeInput( + 6, + 0, + xcffib.xproto.Time.CurrentTime, + screen.root, + x, + y, + 0) + + # press + xtest.FakeInput( + 4, + 1, + xcffib.xproto.Time.CurrentTime, + screen.root, + 0, + 0, + 0) + + # release + xtest.FakeInput( + 5, + 1, + xcffib.xproto.Time.CurrentTime, + screen.root, + 2, + 2, + 0) + xcffib_test.conn.flush() + test(50, 10) + + # we shouldn't get any errors + xcffib_test.conn.poll_for_event() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xcffib-0.11.1/test/test_python_code.py new/xcffib-0.12.1/test/test_python_code.py --- old/xcffib-0.11.1/test/test_python_code.py 2019-12-29 01:30:22.000000000 +0100 +++ new/xcffib-0.12.1/test/test_python_code.py 2022-06-18 16:35:59.000000000 +0200 @@ -20,9 +20,10 @@ import sys from xcffib.xproto import EventMask -from .testing import XcffibTest +from .conftest import XcffibTest -class TestPythonCode(XcffibTest): + +class TestPythonCode: def test_struct_pack_uses_List(self): # suppose we have a list of ints... @@ -65,9 +66,9 @@ assert om[1] == "Event1,0" assert om[2] == "Event1,1" - def test_create_ClientMessageEvent(self): - wm_protocols = self.intern("WM_PROTOCOLS") - wm_delete_window = self.intern("WM_DELETE_WINDOW") + def test_create_ClientMessageEvent(self, xcffib_test): + wm_protocols = xcffib_test.intern("WM_PROTOCOLS") + wm_delete_window = xcffib_test.intern("WM_DELETE_WINDOW") # should be exactly 20 bytes data = [ @@ -81,11 +82,11 @@ union = xcffib.xproto.ClientMessageData.synthetic(data, "I" * 5) assert list(union.data32) == data - wid = self.conn.generate_id() - self.create_window(wid=wid) + wid = xcffib_test.conn.generate_id() + xcffib_test.create_window(wid=wid) - wm_protocols = self.intern("WM_PROTOCOLS") - wm_delete_window = self.intern("WM_DELETE_WINDOW") + wm_protocols = xcffib_test.intern("WM_PROTOCOLS") + wm_delete_window = xcffib_test.intern("WM_DELETE_WINDOW") e = xcffib.xproto.ClientMessageEvent.synthetic( format=32, @@ -94,18 +95,18 @@ data=union ) - self.xproto.SendEvent(False, wid, EventMask.NoEvent, e.pack()) - self.conn.flush() + xcffib_test.xproto.SendEvent(False, wid, EventMask.NoEvent, e.pack()) + xcffib_test.conn.flush() - e = self.conn.wait_for_event() + e = xcffib_test.conn.wait_for_event() assert isinstance(e, xcffib.xproto.ClientMessageEvent) assert e.window == wid assert list(e.data.data32) == data - def test_pack_from_event(self): - wm_protocols = self.intern("WM_PROTOCOLS") - wm_delete_window = self.intern("WM_DELETE_WINDOW") - wid = self.conn.generate_id() + def test_pack_from_event(self, xcffib_test): + wm_protocols = xcffib_test.intern("WM_PROTOCOLS") + wm_delete_window = xcffib_test.intern("WM_DELETE_WINDOW") + wid = xcffib_test.conn.generate_id() # should be exactly 20 bytes data = [ @@ -126,9 +127,9 @@ e2 = xcffib.xproto.ClientMessageEvent(e) - def test_get_image(self): + def test_get_image(self, xcffib_test): # adapted from: https://gist.github.com/liftoff/4741790 - setup = self.conn.get_setup() + setup = xcffib_test.conn.get_setup() screen = setup.roots[0] width = screen.width_in_pixels height = screen.height_in_pixels @@ -137,12 +138,12 @@ # GetImage requires an output format as the first arg. We want ZPixmap: output_format = xcffib.xproto.ImageFormat.ZPixmap plane_mask = 2**32 - 1 # No idea what this is but it works! - reply = self.conn.core.GetImage( + reply = xcffib_test.conn.core.GetImage( output_format, root, 0, 0, width, height, plane_mask).reply() reply.data.buf() -class TestXcffibTestGenerator(object): +class TestXcffibTestGenerator: def test_XcffibTest_generator(self): try: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xcffib-0.11.1/test/testing.py new/xcffib-0.12.1/test/testing.py --- old/xcffib-0.11.1/test/testing.py 2019-12-29 01:30:22.000000000 +0100 +++ new/xcffib-0.12.1/test/testing.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,69 +0,0 @@ -# Copyright 2014 Tycho Andersen -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import xcffib -from xcffib.testing import XvfbTest -from xcffib.xproto import EventMask - - -class XcffibTest(XvfbTest): - """ A home for common functions needed for xcffib testing. """ - - def setUp(self): - XvfbTest.setUp(self) - self.xproto = xcffib.xproto.xprotoExtension(self.conn) - - def tearDown(self): - self.xproto = None - XvfbTest.tearDown(self) - - @property - def default_screen(self): - return self.conn.setup.roots[self.conn.pref_screen] - - def create_window(self, wid=None, x=0, y=0, w=1, h=1, is_checked=False): - if wid is None: - wid = self.conn.generate_id() - return self.xproto.CreateWindow( - self.default_screen.root_depth, - wid, - self.default_screen.root, - x, y, w, h, - 0, - xcffib.xproto.WindowClass.InputOutput, - self.default_screen.root_visual, - xcffib.xproto.CW.BackPixel | xcffib.xproto.CW.EventMask, - [ - self.default_screen.black_pixel, - xcffib.xproto.EventMask.StructureNotify - ], - is_checked=is_checked - ) - - def xeyes(self): - # Enable CreateNotify - self.xproto.ChangeWindowAttributes( - self.default_screen.root, - xcffib.xproto.CW.EventMask, - [ - EventMask.SubstructureNotify | - EventMask.StructureNotify | - EventMask.SubstructureRedirect - ] - ) - - self.spawn(['xeyes']) - - def intern(self, name): - return self.xproto.InternAtom(False, len(name), name).reply().atom diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xcffib-0.11.1/xcffib/__init__.py new/xcffib-0.12.1/xcffib/__init__.py --- old/xcffib-0.11.1/xcffib/__init__.py 2020-11-29 16:55:26.000000000 +0100 +++ new/xcffib-0.12.1/xcffib/__init__.py 2022-09-25 16:44:39.000000000 +0200 @@ -37,8 +37,8 @@ soname = "libxcb.so" lib = ffi.dlopen(soname) -__xcb_proto_version__ = "1.14" -__version__ = "0.11.1" +__xcb_proto_version__ = "1.14.1" +__version__ = "0.12.1" X_PROTOCOL = lib.X_PROTOCOL X_PROTOCOL_REVISION = lib.X_PROTOCOL_REVISION @@ -126,10 +126,11 @@ @classmethod def synthetic(cls, data, format): self = cls.__new__(cls) + self.__init__(len(data)) self.buf = data self.offset = 0 self.size = len(data) - self.size + return self class CffiUnpacker(Unpacker): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xcffib-0.11.1/xcffib/testing.py new/xcffib-0.12.1/xcffib/testing.py --- old/xcffib-0.11.1/xcffib/testing.py 2020-11-29 16:55:26.000000000 +0100 +++ new/xcffib-0.12.1/xcffib/testing.py 2022-09-25 16:44:39.000000000 +0200 @@ -44,7 +44,7 @@ return display, f -class XvfbTest(object): +class XvfbTest: """ A helper class for testing things with nosetests. This class will run each test in its own fresh xvfb, leaving you with an xcffib connection to @@ -61,7 +61,13 @@ def spawn(self, cmd): """ Spawn a command but swallow its output. """ - return subprocess.Popen(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + return subprocess.Popen(cmd) + + def _restore_display(self): + if self._old_display is None: + del os.environ['DISPLAY'] + else: + os.environ['DISPLAY'] = self._old_display def setUp(self): self._old_display = os.environ.get('DISPLAY') @@ -74,7 +80,11 @@ # xtrace's default display is :9; obviously this won't work # concurrently, but it's not the default so... os.environ['DISPLAY'] = ':9' - self.conn = self._connect_to_xvfb() + try: + self.conn = self._connect_to_xvfb() + except AssertionError: + self._restore_display() + raise def tearDown(self): try: @@ -100,11 +110,8 @@ # cleaned it up during a test. if e.errno != errno.ENOENT: raise - - if self._old_display is None: - del os.environ['DISPLAY'] - else: - os.environ['DISPLAY'] = self._old_display + finally: + self._restore_display() def __enter__(self): self.setUp() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xcffib-0.11.1/xcffib.egg-info/PKG-INFO new/xcffib-0.12.1/xcffib.egg-info/PKG-INFO --- old/xcffib-0.11.1/xcffib.egg-info/PKG-INFO 2020-11-29 16:55:27.000000000 +0100 +++ new/xcffib-0.12.1/xcffib.egg-info/PKG-INFO 2022-09-25 16:44:39.000000000 +0200 @@ -1,12 +1,11 @@ -Metadata-Version: 1.1 +Metadata-Version: 2.1 Name: xcffib -Version: 0.11.1 +Version: 0.12.1 Summary: A drop in replacement for xpyb, an XCB python binding Home-page: http://github.com/tych0/xcffib Author: Tycho Andersen Author-email: tycho@tycho.pizza License: Apache License 2.0 -Description: UNKNOWN Keywords: xcb xpyb cffi x11 x windows Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable @@ -19,3 +18,7 @@ Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Topic :: Software Development :: Libraries +License-File: LICENSE + +UNKNOWN + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xcffib-0.11.1/xcffib.egg-info/SOURCES.txt new/xcffib-0.12.1/xcffib.egg-info/SOURCES.txt --- old/xcffib-0.11.1/xcffib.egg-info/SOURCES.txt 2020-11-29 16:55:27.000000000 +0100 +++ new/xcffib-0.12.1/xcffib.egg-info/SOURCES.txt 2022-09-25 16:44:39.000000000 +0200 @@ -3,11 +3,11 @@ README.md setup.py test/__init__.py +test/conftest.py test/test_connection.py test/test_crazy_window_script.py test/test_fakeinput.py test/test_python_code.py -test/testing.py xcffib/__init__.py xcffib/bigreq.py xcffib/composite.py