You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm developing kivy app to run in 3 major OS (linux, windows, mac) and currently writing simple unit tests with the GraphicalUnitTest class in a github-action:
classTestBaseScreen(GraphicUnitTest):
@patch.object(EventLoopBase, "ensure_window", lambdax: None)deftest_render(self):
screen=BaseScreen(wid="mock", name="Mock")
self.render(screen)
# get your Window instance safelyEventLoop.ensure_window()
window=EventLoop.window# your assertsself.assertEqual(window.children[0], screen)
self.assertEqual(window.children[0].height, window.height)
Where BaseScreen is a subclass of Screen (see source here).
EDIT
The test setup in github is:
- name: Install dependenciesrun: | python3 -m pip install --upgrade pip python3 -m pip install poetry
- name: Install project and its dependenciesrun: poetry install
- name: Run tests (Linux)if: ${{ runner.os == 'Linux' }}uses: coactions/setup-xvfb@v1with:
run: | poetry add pytest-xvfb poetry run poe test
- name: Run tests (Windows)if: ${{ runner.os == 'Windows' }}env:
KIVY_GL_BACKEND: 'angle_sdl2'run: poetry run poe test
- name: Run tests (macOS)if: ${{ runner.os == 'macOS' }}env:
USE_SDL2: 1KIVY_GL_BACKEND: 'sdl2'run: poetry run poe test
This works well in Linux machine since an Xvfb and pytest-xvfb plugin was used for this purpose. This is working well in Windows using KIVY_GL_BACKEND=angle_sdl2. All environment variables are from Kivy workflows.
However,macos runners do not occur properly. The pytest start to be executed and when the graphics tests are started, an error is reported:
_________________________ TestBaseScreen.test_on_press _________________________
self = <tests.test_030_base_screen.TestBaseScreen testMethod=test_on_press>
def setUp(self):
'''Prepare the graphic test, with: - Window size fixed to 320x240 - Default kivy configuration - Without any kivy input'''# use default kivy configuration (don't load user file.)
from os import environ
environ['KIVY_USE_DEFAULTCONFIG'] = '1'# force window size + remove all inputs
from kivy.config import Config
Config.set('graphics', 'width', '320')
Config.set('graphics', 'height', '240')
foritemsin Config.items('input'):
Config.remove_option('input', items[0])
# bind ourself for the later screenshot
from kivy.core.window import Window
self.Window = Window
> Window.bind(on_flip=self.on_window_flip)
E AttributeError: 'NoneType' object has no attribute 'bind'
I believe that such errors happen because runners do not have a graphical interface. But i don´t know how to fix it. It is in this sense that I come to SO for help, that is, run the graphical tests on MacOS, despite the lack of a window manager, in the same way as was done on the Linux/Windows runners.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Summary of situation
I'm developing kivy app to run in 3 major OS (linux, windows, mac) and currently writing simple unit tests with the
GraphicalUnitTest
class in a github-action:Where
BaseScreen
is a subclass ofScreen
(see source here).EDIT
The test setup in github is:
This works well in Linux machine since an Xvfb and pytest-xvfb plugin was used for this purpose. This is working well in Windows using
KIVY_GL_BACKEND=angle_sdl2
. All environment variables are from Kivy workflows.However,
macos
runners do not occur properly. Thepytest
start to be executed and when the graphics tests are started, an error is reported:I believe that such errors happen because runners do not have a graphical interface. But i don´t know how to fix it. It is in this sense that I come to SO for help, that is, run the graphical tests on MacOS, despite the lack of a window manager, in the same way as was done on the Linux/Windows runners.
Thanks in advance
Beta Was this translation helpful? Give feedback.
All reactions