added pytest, moved dependencies
parent
c6c768eb77
commit
7ff4f5d059
|
|
@ -77,9 +77,6 @@ dependencies = [
|
|||
"trio-typing>=0.10.0",
|
||||
"numba>=0.61.0",
|
||||
"pyvnc",
|
||||
"pyqt6>=6.8.0",
|
||||
"pyqtgraph>=0.12.3",
|
||||
"qdarkstyle>=3.2.3",
|
||||
]
|
||||
|
||||
[project.optional-dependencies]
|
||||
|
|
@ -88,9 +85,6 @@ uis = [
|
|||
# TODO: make sure the levenshtein shit compiles on nix..
|
||||
# rapidfuzz = {extras = ["speedup"], version = "^0.18.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,
|
||||
# - 'visidata'
|
||||
|
|
@ -121,6 +115,10 @@ dev = [
|
|||
|
||||
# ?from git, see below.
|
||||
"xonsh",
|
||||
"qdarkstyle >=3.0.2, <4.0.0",
|
||||
"pyqt6 >=6.7.0, <7.0.0",
|
||||
"pyqtgraph",
|
||||
|
||||
]
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
|
|
|
|||
|
|
@ -1,18 +1,34 @@
|
|||
from PyQt6 import QtGui
|
||||
import pytest
|
||||
from piker.ui._style import DpiAwareFont
|
||||
|
||||
class MockScreen:
|
||||
def __init__(self, pdpi, ldpi, name="MockScreen"):
|
||||
self._pdpi = pdpi
|
||||
self._ldpi = ldpi
|
||||
self._name = name
|
||||
|
||||
def physicalDotsPerInch(self):
|
||||
return 169 # example HiDPI
|
||||
return self._pdpi
|
||||
|
||||
def logicalDotsPerInch(self):
|
||||
return 96
|
||||
return self._ldpi
|
||||
|
||||
def name(self):
|
||||
return "MockScreen"
|
||||
return self._name
|
||||
|
||||
# create font instance
|
||||
font = DpiAwareFont()
|
||||
@pytest.mark.parametrize(
|
||||
"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
|
||||
font.configure_to_dpi(screen=MockScreen())
|
||||
px = font.px_size
|
||||
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