Skip to content

Commit

Permalink
Merge pull request #532 from gaphor/fix-test-runs-in-vscode
Browse files Browse the repository at this point in the history
Fix test discovery issue in VSCode
  • Loading branch information
amolenaar committed Dec 1, 2020
2 parents 55b5316 + d7aef77 commit 6c912ab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 7 additions & 3 deletions gaphor/ui/diagrampage.py
Expand Up @@ -41,8 +41,12 @@ def tooliter(toolbox_actions: Sequence[Tuple[str, Sequence[ToolDef]]]):
yield from section


with importlib.resources.path("gaphor.ui", "placement-icon-base.png") as f:
PLACEMENT_BASE = GdkPixbuf.Pixbuf.new_from_file_at_scale(str(f), 64, 64, True)
@functools.lru_cache(maxsize=1)
def placement_icon_base():
with importlib.resources.path("gaphor.ui", "placement-icon-base.png") as f:
print(str(f))
return GdkPixbuf.Pixbuf.new_from_file_at_scale(str(f), 64, 64, True)


GtkView.set_css_name("diagramview")

Expand All @@ -62,7 +66,7 @@ def get_placement_cursor(display, icon_name):
if icon_name in _placement_pixbuf_map:
pixbuf = _placement_pixbuf_map[icon_name]
else:
pixbuf = PLACEMENT_BASE.copy()
pixbuf = placement_icon_base().copy()
icon = Gtk.IconTheme.get_default().load_icon(icon_name, 24, 0)
icon.copy_area(
0,
Expand Down
10 changes: 9 additions & 1 deletion gaphor/ui/tests/test_diagrampage.py
Expand Up @@ -3,7 +3,7 @@
from gaphor.core.modeling import Comment, Diagram, StyleSheet
from gaphor.diagram.general import Box
from gaphor.diagram.general.comment import CommentItem
from gaphor.ui.diagrams import DiagramPage
from gaphor.ui.diagrampage import DiagramPage, placement_icon_base
from gaphor.UML.modelinglanguage import UMLModelingLanguage


Expand Down Expand Up @@ -31,3 +31,11 @@ def test_placement(diagram, page, element_factory):

diagram.create(CommentItem, subject=element_factory.create(Comment))
assert len(element_factory.lselect()) == 3


@pytest.mark.skip(reason="This test cases a Segmentation Fault when run from VSCode")
def test_placement_icon_base_is_loaded_once():
icon1 = placement_icon_base()
icon2 = placement_icon_base()

assert icon1 is icon2

0 comments on commit 6c912ab

Please sign in to comment.