Closed ReenigneArcher closed 2 years ago
I was able to get past the error above by creating a dummy display server.
However receiving new errors now:
==================================== ERRORS ====================================
_____________________ ERROR at setup of test_tray_disable ______________________
@pytest.fixture(scope='module')
def test_tray_icon():
"""Initialize and run a test tray icon"""
test_tray_icon = tray_icon.tray_initialize()
> tray_icon.tray_run()
tests/conftest.py:60:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pyra/tray_icon.py:99: in tray_run
icon.run_detached()
/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/site-packages/pystray/_base.py:242: in run_detached
self._run_detached()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pystray._xorg.Icon object at 0x7f159b353790>
def _run_detached(self):
"""Runs detached.
This method must call :meth:`_mark_ready` once ready.
This is a platform dependent implementation.
"""
> raise NotImplementedError()
E NotImplementedError
/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/site-packages/pystray/_base.py:384: NotImplementedError
_______________________ ERROR at setup of test_tray_end ________________________
@pytest.fixture(scope='module')
def test_tray_icon():
"""Initialize and run a test tray icon"""
test_tray_icon = tray_icon.tray_initialize()
> tray_icon.tray_run()
tests/conftest.py:60:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pyra/tray_icon.py:99: in tray_run
icon.run_detached()
/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/site-packages/pystray/_base.py:242: in run_detached
self._run_detached()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pystray._xorg.Icon object at 0x7f159b353790>
def _run_detached(self):
"""Runs detached.
This method must call :meth:`_mark_ready` once ready.
This is a platform dependent implementation.
"""
> raise NotImplementedError()
E NotImplementedError
/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/site-packages/pystray/_base.py:384: NotImplementedError
_______________________ ERROR at setup of test_tray_run ________________________
@pytest.fixture(scope='module')
def test_tray_icon():
"""Initialize and run a test tray icon"""
test_tray_icon = tray_icon.tray_initialize()
> tray_icon.tray_run()
tests/conftest.py:60:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pyra/tray_icon.py:99: in tray_run
icon.run_detached()
/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/site-packages/pystray/_base.py:242: in run_detached
self._run_detached()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pystray._xorg.Icon object at 0x7f159b353790>
def _run_detached(self):
"""Runs detached.
This method must call :meth:`_mark_ready` once ready.
This is a platform dependent implementation.
"""
> raise NotImplementedError()
E NotImplementedError
/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/site-packages/pystray/_base.py:384: NotImplementedError
=================================== FAILURES ===================================
_____________________________ test_tray_initialize _____________________________
def test_tray_initialize():
"""Test tray initialization"""
tray = tray_icon.tray_initialize()
assert isinstance(tray, pystray.Icon)
# these test whether the OS supports the feature, not if the menu has the feature
> assert tray.HAS_MENU
E assert False
E + where False = <pystray._xorg.Icon object at 0x7f1591c10250>.HAS_MENU
tests/unit/test_tray_icon.py:19: AssertionError
=========================== short test summary info ============================
FAILED tests/unit/test_tray_icon.py::test_tray_initialize - assert False
ERROR tests/unit/test_tray_icon.py::test_tray_disable - NotImplementedError
ERROR tests/unit/test_tray_icon.py::test_tray_end - NotImplementedError
ERROR tests/unit/test_tray_icon.py::test_tray_run - NotImplementedError
==================== 1 failed, 40 passed, 3 errors in 7.57s ====================
I've installed the following packages, and really at a loss as to what I could be missing.
Thank your for your report.
By importing pystray with the appindicator
backend and checking from which file the introspection data was loaded (/usr/lib/girepository-1.0/AppIndicator3-0.1.typelib
), I managed to determine that the package needed on Ubuntu is gir1.2-appindicator3-0.1
. I doubt, however, that you will manage to get it running in a github runner, since the backends on Linux generally will not run headless.
However, your second error has revealed a bug in the Xorg backend implementation introduced in commit 558aa1663dd3e9682c673145ee88d194b00b9b5b, which I will try to fix swiftly.
However, your second error has revealed a bug in the Xorg backend implementation introduced in commit 558aa16, which I will try to fix swiftly.
Are you referring to the run_detached
method? For now I'm using a try/except on that; however I'm unable to run this in the main thread. It doesn't totally make sense why it needs to run in the main thread in some cases. Perhaps that could be made more clear in the docs.
Either way, thank you for this tool!
What are the required libraries to run this in ubuntu? Specifically I am attempting to test my application with pytest in a github runner using Ubuntu 20.04; however this is Ubuntu server.
I have attempted installing each of these packages, although not at the same time.
This is the traceback when using
ubuntu-desktop
although each gave the same error at the end, just slightly different tracebacks.The pytest works in both windows and macos runners.
Any guidance would be appreciated. Of course as I'm running this in a github runner I don't actually need to see the icon, I just want to test that the icon is created properly using the
pystray.Icon()
class.