-
-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Just a simple one, that checks if the correct Gtk version gets installed. Note this test is checks for the linked regression only if both Gtk3 and Gtk4 are installed. Otherwise, it checks if brain_gi works at all.
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html | ||
# For details: https://github.com/pylint-dev/astroid/blob/main/LICENSE | ||
# Copyright (c) https://github.com/pylint-dev/astroid/blob/main/CONTRIBUTORS.txt | ||
|
||
import warnings | ||
from importlib.util import find_spec | ||
|
||
import pytest | ||
|
||
from astroid import Uninferable, extract_node | ||
from astroid.bases import BoundMethod | ||
from astroid.manager import AstroidManager | ||
|
||
HAS_GI = find_spec("gi") | ||
|
||
|
||
@pytest.mark.skipif(HAS_GI is None, reason="These tests require the gi library.") | ||
class TestBrainGi: | ||
AstroidManager.brain["extension_package_whitelist"] = {"gi"} # noqa: RUF012 | ||
|
||
@staticmethod | ||
def test_import() -> None: | ||
"""Regression test for https://github.com/pylint-dev/astroid/issues/2190""" | ||
src = """ | ||
import gi | ||
gi.require_version('Gtk', '3.0') | ||
from gi.repository import Gtk | ||
cell = Gtk.CellRendererText() | ||
cell.props.xalign = 1.0 | ||
Gtk.Builder().connect_signals | ||
""" | ||
with warnings.catch_warnings(): | ||
# gi uses pkgutil.get_loader | ||
warnings.filterwarnings("ignore", category=DeprecationWarning) | ||
node = extract_node(src) | ||
attribute_node = node.inferred()[0] | ||
if attribute_node is Uninferable: | ||
pytest.skip("Gtk3 may not be installed?") | ||
assert isinstance(attribute_node, BoundMethod) |