Skip to content

utils

get_test_data_dir()

As we moved all resources from tests/client/ayon_core/ui to tests/client/ayon_core/ui/test_data we need to be able to find the test data directory.

Source code in client/ayon_core/ui/preview_utils/utils.py
55
56
57
58
59
60
61
62
63
64
65
def get_test_data_dir() -> Path:
    """
    As we moved all resources
    from `tests/client/ayon_core/ui` to `tests/client/ayon_core/ui/test_data`
    we need to be able to find the test data directory.
    """

    # Relative to repo root path tests/client/ayon_core/ui/test_data
    return (
        REPO_ROOT / "tests" / "client" / "ayon_core" / "ui" / "test_data"
    )

preview_widget(create_widget_func, style=Style.AYONStyleOverCSS)

Main function to run the Qt test.

Source code in client/ayon_core/ui/preview_utils/utils.py
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
def preview_widget(
    create_widget_func, style: Style = Style.AYONStyleOverCSS
) -> None:
    """Main function to run the Qt test."""
    app = QtWidgets.QApplication(sys.argv)

    if style == Style.CSS:
        # Set old RV dark theme for the application
        app.setStyleSheet(_load_rv_stylesheet())
    elif style == Style.AYONStyle:
        app.setStyle(get_ayon_style())
    elif style == Style.AYONStyleOverCSS:
        app.setStyleSheet(_load_rv_stylesheet())

    # Create and show the test widget
    widget = create_widget_func()

    if style == Style.AYONStyleOverCSS:
        widget.setStyle(get_ayon_style())

    widget.show()

    print("Qt widget preview started. Close the window to exit.")
    return app.exec()