mirror of
https://github.com/pyapp-kit/superqt.git
synced 2025-12-15 18:50:05 +01:00
fix: fix deprecation warning on fonticon plugin discovery on python 3.10 (#95)
* fix: fix fonticon * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix entry points API Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
Metadata-Version: 2.1
|
||||
Name: fake-plugin
|
||||
Version: 5.15.4
|
||||
@@ -0,0 +1,2 @@
|
||||
[superqt.fonticon]
|
||||
ico = fake_plugin:ICO
|
||||
@@ -0,0 +1 @@
|
||||
fake_plugin
|
||||
6
tests/test_fonticon/fixtures/fake_plugin/__init__.py
Normal file
6
tests/test_fonticon/fixtures/fake_plugin/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class ICO:
|
||||
__font_file__ = str(Path(__file__).parent / "icontest.ttf")
|
||||
smiley = "ico.\ue900"
|
||||
@@ -11,7 +11,7 @@ TEST_PREFIX = "ico"
|
||||
TEST_CHARNAME = "smiley"
|
||||
TEST_CHAR = "\ue900"
|
||||
TEST_GLYPHKEY = f"{TEST_PREFIX}.{TEST_CHARNAME}"
|
||||
FONT_FILE = Path(__file__).parent / "icontest.ttf"
|
||||
FONT_FILE = Path(__file__).parent / "fixtures" / "fake_plugin" / "icontest.ttf"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -7,41 +7,15 @@ 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"
|
||||
FIXTURES = Path(__file__).parent / "fixtures"
|
||||
|
||||
|
||||
@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()]
|
||||
|
||||
_path = [str(FIXTURES)] + sys.path.copy()
|
||||
store = QFontIconStore().instance()
|
||||
with monkeypatch.context() as m:
|
||||
m.setattr(sys, "meta_path", [MockFinder()])
|
||||
m.setattr(sys, "path", _path)
|
||||
yield store
|
||||
store.clear()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user