File: test_plugins.py

package info (click to toggle)
superqt 0.7.8-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,328 kB
  • sloc: python: 9,162; makefile: 16; sh: 12
file content (28 lines) | stat: -rw-r--r-- 723 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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

FIXTURES = Path(__file__).parent / "fixtures"


@pytest.fixture
def plugin_store(qapp, monkeypatch):
    _path = [str(FIXTURES), *sys.path.copy()]
    store = QFontIconStore().instance()
    with monkeypatch.context() as m:
        m.setattr(sys, "path", _path)
        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)