• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SPF-OST / pytrnsys_gui / 17585105057

09 Sep 2025 02:00PM UTC coverage: 67.83% (-0.004%) from 67.834%
17585105057

push

github

web-flow
Merge pull request #607 from SPF-OST/nice-message-if-resources-not-generated

Give a nicer message if resources haven't been generated.

3 of 6 new or added lines in 1 file covered. (50.0%)

10460 of 15421 relevant lines covered (67.83%)

0.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.0
/trnsysGUI/dialogs/__init__.py
1
__all__ = [
1✔
2
    "assertThatGeneratedUIModuleAndResourcesExist",
3
    "assertThatLocalGeneratedUIModuleAndResourcesExist",
4
]
5

6
import importlib as _il
1✔
7

8
_ERROR_MESSAGE = (
1✔
9
    "Could not find the generated Python code for a .ui or .qrc file. Please run the "
10
    "`dev-tools\\generateGuiClassesFromQtCreatorStudioUiFiles.py' script from your "
11
    "`pytrnsys_gui` directory."
12
)
13

14
# This module needs to be imported at least once as it registers resources (icons, etc) with QT
15
# upon being imported. So even though it looks like an unused import DON'T REMOVE IT
16
try:
1✔
17
    import trnsysGUI.resources.QRC_resources_generated as _qresources
1✔
NEW
18
except ImportError as importError:
×
NEW
19
    raise AssertionError(_ERROR_MESSAGE) from importError
×
20

21
DEFAULT_MODULE_NAME = "_UI_dialog_generated"
1✔
22

23

24
def assertThatGeneratedUIModuleAndResourcesExist(
1✔
25
    packageName: str, *, moduleName: str = DEFAULT_MODULE_NAME
26
) -> None:
27
    try:
1✔
28
        _il.import_module(f".{moduleName}", packageName)
1✔
29
    except ImportError as importError:
×
30

NEW
31
        raise AssertionError(_ERROR_MESSAGE) from importError
×
32

33

34
def assertThatLocalGeneratedUIModuleAndResourcesExist(
1✔
35
    absoluteModuleName: str, *, moduleName: str = DEFAULT_MODULE_NAME
36
) -> None:
37
    """This functions assumes that the module to import is next to the calling module in the file hierarchy."""
38
    packageName = ".".join(absoluteModuleName.split(".")[:-1])
1✔
39
    assertThatGeneratedUIModuleAndResourcesExist(
1✔
40
        packageName, moduleName=moduleName
41
    )
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc