added pytest, moved dependencies
parent
c6c768eb77
commit
7ff4f5d059
|
|
@ -77,9 +77,6 @@ dependencies = [
|
||||||
"trio-typing>=0.10.0",
|
"trio-typing>=0.10.0",
|
||||||
"numba>=0.61.0",
|
"numba>=0.61.0",
|
||||||
"pyvnc",
|
"pyvnc",
|
||||||
"pyqt6>=6.8.0",
|
|
||||||
"pyqtgraph>=0.12.3",
|
|
||||||
"qdarkstyle>=3.2.3",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[project.optional-dependencies]
|
[project.optional-dependencies]
|
||||||
|
|
@ -88,9 +85,6 @@ uis = [
|
||||||
# TODO: make sure the levenshtein shit compiles on nix..
|
# TODO: make sure the levenshtein shit compiles on nix..
|
||||||
# rapidfuzz = {extras = ["speedup"], version = "^0.18.0"}
|
# rapidfuzz = {extras = ["speedup"], version = "^0.18.0"}
|
||||||
"rapidfuzz >=3.2.0, <4.0.0",
|
"rapidfuzz >=3.2.0, <4.0.0",
|
||||||
"qdarkstyle >=3.0.2, <4.0.0",
|
|
||||||
"pyqt6 >=6.7.0, <7.0.0",
|
|
||||||
"pyqtgraph",
|
|
||||||
|
|
||||||
# for consideration,
|
# for consideration,
|
||||||
# - 'visidata'
|
# - 'visidata'
|
||||||
|
|
@ -121,6 +115,10 @@ dev = [
|
||||||
|
|
||||||
# ?from git, see below.
|
# ?from git, see below.
|
||||||
"xonsh",
|
"xonsh",
|
||||||
|
"qdarkstyle >=3.0.2, <4.0.0",
|
||||||
|
"pyqt6 >=6.7.0, <7.0.0",
|
||||||
|
"pyqtgraph",
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,34 @@
|
||||||
from PyQt6 import QtGui
|
import pytest
|
||||||
from piker.ui._style import DpiAwareFont
|
from piker.ui._style import DpiAwareFont
|
||||||
|
|
||||||
class MockScreen:
|
class MockScreen:
|
||||||
|
def __init__(self, pdpi, ldpi, name="MockScreen"):
|
||||||
|
self._pdpi = pdpi
|
||||||
|
self._ldpi = ldpi
|
||||||
|
self._name = name
|
||||||
|
|
||||||
def physicalDotsPerInch(self):
|
def physicalDotsPerInch(self):
|
||||||
return 169 # example HiDPI
|
return self._pdpi
|
||||||
|
|
||||||
def logicalDotsPerInch(self):
|
def logicalDotsPerInch(self):
|
||||||
return 96
|
return self._ldpi
|
||||||
|
|
||||||
def name(self):
|
def name(self):
|
||||||
return "MockScreen"
|
return self._name
|
||||||
|
|
||||||
# create font instance
|
@pytest.mark.parametrize(
|
||||||
font = DpiAwareFont()
|
"pdpi, ldpi",
|
||||||
|
[
|
||||||
|
(96, 96), # normal DPI
|
||||||
|
(169, 96), # HiDPI
|
||||||
|
(120, 96), # mid-DPI
|
||||||
|
]
|
||||||
|
)
|
||||||
|
def test_font_px_size(pdpi, ldpi):
|
||||||
|
font = DpiAwareFont()
|
||||||
|
font.configure_to_dpi(screen=MockScreen(pdpi, ldpi))
|
||||||
|
|
||||||
# pass the mock screen to configure_to_dpi
|
px = font.px_size
|
||||||
font.configure_to_dpi(screen=MockScreen())
|
print(f"{pdpi}x{ldpi} DPI -> Computed pixel size: {px}")
|
||||||
|
|
||||||
print("Computed pixel size:", font.px_size)
|
assert 12 <= px <= 24
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue