Xpra: Ticket #1963: TestX11Keyboard failure with GTK3

Occurs when running the unit tests without a DISPLAY:

$ DISPLAY= ./run3
(..)
running unit.x11.keyboard_test
Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused
E
======================================================================
ERROR: test_unicode (__main__.TestX11Keyboard)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/antoine/projects/Xpra/trunk/src/unittests/unit/x11/keyboard_test.py", line 21, in test_unicode
    keyboard_bindings = X11KeyboardBindings()
  File "xpra/x11/bindings/keyboard_bindings.pyx", line 253, in xpra.x11.bindings.keyboard_bindings.X11KeyboardBindings
  File "xpra/x11/bindings/core_bindings.pyx", line 83, in xpra.x11.bindings.core_bindings._X11CoreBindings.__cinit__
  File "/home/antoine/projects/Xpra/trunk/src/install/python3/lib64/python/xpra/os_util.py", line 272, in is_X11
    x11 = is_X11_Display()
  File "xpra/x11/gtk3/gdk_bindings.pyx", line 54, in xpra.x11.gtk3.gdk_bindings.is_X11_Display
  File "xpra/gtk_common/gtk3/gdk_bindings.pyx", line 64, in xpra.gtk_common.gtk3.gdk_bindings.get_raw_display_for
  File "xpra/gtk_common/gtk3/gdk_bindings.pyx", line 50, in xpra.gtk_common.gtk3.gdk_bindings.get_display_for
TypeError: Cannot get a display: instance is None!

Strangely enough, running the test directly works:

$ XPRA_ALL_DEBUG=1 DISPLAY= PYTHONPATH=. ./unit/x11/keyboard_test.py
2018-09-18 22:19:38,370 socket_details(0, None, None) sockdir=/tmp, sockdirs=['/tmp'], testing=['/tmp']
2018-09-18 22:19:38,372 stdout: /tmp/xpra-stdout-WVcbKp for 'python2' '/usr/bin/xpra' '--speaker=no' '--microphone=no' '--systemd-run=no' '--pulseaudio=no' '--socket-dirs=/tmp' 'list'
2018-09-18 22:19:38,373 stderr: /tmp/xpra-stderr-en3NBc for 'python2' '/usr/bin/xpra' '--speaker=no' '--microphone=no' '--systemd-run=no' '--pulseaudio=no' '--socket-dirs=/tmp' 'list'
2018-09-18 22:19:38,775 socket_details(0, None, None) sockdir=/tmp, sockdirs=['/tmp'], testing=['/tmp']
2018-09-18 22:19:38,781 stdout=/tmp/Xorg-stdout-Kxps3m for ['/usr/libexec/Xorg', '-noreset', '-novtswitch', '-nolisten', 'tcp', '+extension', 'GLX', '+extension', 'RANDR', '+extension', 'RENDER', '-auth', '$XAUTHORITY', '-logfile', '${XPRA_LOG_DIR}/Xorg.${DISPLAY}.log', '-configdir', '/run/user/1000/xpra/xorg.conf.d/8993', '-config', '/etc/xpra/xorg.conf', ':100']
2018-09-18 22:19:38,781 stderr=/tmp/Xorg-stderr-KNw30h for ['/usr/libexec/Xorg', '-noreset', '-novtswitch', '-nolisten', 'tcp', '+extension', 'GLX', '+extension', 'RANDR', '+extension', 'RENDER', '-auth', '$XAUTHORITY', '-logfile', '${XPRA_LOG_DIR}/Xorg.${DISPLAY}.log', '-configdir', '/run/user/1000/xpra/xorg.conf.d/8993', '-config', '/etc/xpra/xorg.conf', ':100']
2018-09-18 22:19:39,784 xvfb('/usr/libexec/Xorg' '-noreset' '-novtswitch' '-nolisten' 'tcp' '+extension' 'GLX' '+extension' 'RANDR' '+extension' 'RENDER' '-auth' '$XAUTHORITY' '-logfile' '/tmp/Xorg.:100.log' '-configdir' '/run/user/1000/xpra/xorg.conf.d/8993' '-config' '/etc/xpra/xorg.conf' ':100')=<subprocess.Popen object at 0x7f5f82bb6710>
.2018-09-18 22:19:47,813 socket_details(0, None, None) sockdir=/tmp, sockdirs=['/tmp'], testing=['/tmp']


Thu, 20 Sep 2018 04:59:32 GMT - Antoine Martin: status changed; resolution set

r20466 fixes this particular problem.

The problem didn't occur with GTK2 because we know we can't support native wayland so we don't need to check the $DISPLAY with native calls. With GTK3, we need it and the environment was (wrongly) being protected from modifications, now we just restore it before each test instead.

Lots of other test related changes and fixes (XAUTHORITY, etc): r20459, r20460, r20465, r20466, r20467, r20468, r20469, r20471 And yet more in #1965..


Sat, 23 Jan 2021 05:38:29 GMT - migration script:

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/1963