Skip to content

Commit

Permalink
refactor: drop is_test_environment, the code using headless kivy sh…
Browse files Browse the repository at this point in the history
…ould be responsible for setting up the environment so that it can fully customize the configuration
  • Loading branch information
sassanh committed Jul 1, 2024
1 parent afb07f7 commit 702a572
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 20 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Version 0.8.1

- refactor: drop `is_test_environment`, the code using headless kivy should be
responsible for setting up the environment so that it can fully customize the
configuration

## Version 0.8.0

- refactor: use `str_to_bool` of `python-strtobool` instead of `strtobool` of `distutils`
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Kivy Headless Renderer for Raspberry Pi
# Kivy Headless Renderer

This project uses the Kivy framework to create a headless renderer
for a Raspberry Pi. The renderer is specifically designed for and tested with the
Expand Down
4 changes: 2 additions & 2 deletions headless_kivy_pi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
To increase fps to `max_fps` call `activate_high_fps_mode`.
"""

from __future__ import annotations

import time
Expand Down Expand Up @@ -60,8 +61,7 @@ class HeadlessWidget(Widget):

def __init__(self: HeadlessWidget, **kwargs: dict[str, object]) -> None:
"""Initialize a `HeadlessWidget`."""
if not config.is_test_environment():
config.check_initialized()
config.check_initialized()

self.should_ignore_hash = False

Expand Down
15 changes: 1 addition & 14 deletions headless_kivy_pi/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,7 @@ def setup_headless_kivy(

from kivy.metrics import dp

if is_test_environment():
Config.set('graphics', 'window_state', 'hidden')
from kivy.core.window import Window

_display = Fake()
elif IS_RPI:
if IS_RPI:
Config.set('graphics', 'window_state', 'hidden')
# Configuration for CS and DC pins (these are PiTFT defaults):
cs_pin = digitalio.DigitalInOut(board.CE0)
Expand Down Expand Up @@ -253,14 +248,6 @@ def is_debug_mode() -> bool:
report_uninitialized()


@cache
def is_test_environment() -> bool:
"""Return `True` if the application is running in test environment."""
import os

return 'PYTEST_CURRENT_TEST' in os.environ


@cache
def double_buffering() -> bool:
"""Generate the next frame while sending the last frame to the display."""
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[tool.poetry]
name = "headless-kivy-pi"
version = "0.8.0"
description = "Headless renderer for Kivy framework on Raspberry Pi"
version = "0.8.1"
description = "Headless renderer for Kivy framework"
authors = ["Sassan Haradji <[email protected]>"]
license = "Apache-2.0"
readme = "README.md"
homepage = 'https://github.com/sassanh/headless-kivy-pi/'
repository = 'https://github.com/sassanh/headless-kivy-pi/'
keywords = ['kivy', 'raspberry-pi', 'headless', 'display']
keywords = ['kivy', 'headless', 'display', 'pytest']
packages = [
{ include = "headless_kivy_pi" },
{ include = "headless_kivy_pi_pytest" },
Expand Down

0 comments on commit 702a572

Please sign in to comment.