mirror of
https://github.com/pyapp-kit/superqt.git
synced 2025-07-21 12:11:07 +02:00
* remove qtcompat * change imports * change codecov * add dep * run tests against dalthviz branch * update * more replace * pin pyside6 for sake of test * add deprecation * drop qt 5.11 * unpin pyside6
55 lines
1.3 KiB
Python
55 lines
1.3 KiB
Python
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
from qtpy.QtGui import QIcon, QPixmap
|
|
|
|
from superqt.fonticon import _plugins, icon
|
|
from superqt.fonticon._qfont_icon import QFontIconStore
|
|
|
|
try:
|
|
from importlib.metadata import Distribution
|
|
except ImportError:
|
|
from importlib_metadata import Distribution # type: ignore
|
|
|
|
|
|
class ICO:
|
|
__font_file__ = str(Path(__file__).parent / "icontest.ttf")
|
|
smiley = "ico.\ue900"
|
|
|
|
|
|
@pytest.fixture
|
|
def plugin_store(qapp, monkeypatch):
|
|
class MockEntryPoint:
|
|
name = "ico"
|
|
group = _plugins.FontIconManager.ENTRY_POINT
|
|
value = "fake_plugin.ICO"
|
|
|
|
def load(self):
|
|
return ICO
|
|
|
|
class MockFinder:
|
|
def find_distributions(self, *a):
|
|
class D(Distribution):
|
|
name = "mock"
|
|
|
|
@property
|
|
def entry_points(self):
|
|
return [MockEntryPoint()]
|
|
|
|
return [D()]
|
|
|
|
store = QFontIconStore().instance()
|
|
with monkeypatch.context() as m:
|
|
m.setattr(sys, "meta_path", [MockFinder()])
|
|
yield store
|
|
store.clear()
|
|
|
|
|
|
def test_plugin(plugin_store):
|
|
assert not _plugins.loaded()
|
|
icn = icon("ico.smiley")
|
|
assert _plugins.loaded() == {"ico": ["smiley"]}
|
|
assert isinstance(icn, QIcon)
|
|
assert isinstance(icn.pixmap(40, 40), QPixmap)
|