Commit 6c4319b0 authored by Adrian Georgescu's avatar Adrian Georgescu

Added workaround for getting unit testing working during debuild

parent 6ceff169
...@@ -6,6 +6,7 @@ import imghdr ...@@ -6,6 +6,7 @@ import imghdr
import os import os
import platform import platform
import sys import sys
import pathlib
from PyQt5.QtCore import Qt, QBuffer from PyQt5.QtCore import Qt, QBuffer
from PyQt5.QtGui import QIcon, QPixmap from PyQt5.QtGui import QIcon, QPixmap
...@@ -60,6 +61,7 @@ class Resources(object): ...@@ -60,6 +61,7 @@ class Resources(object):
@classproperty @classproperty
def directory(cls): def directory(cls):
if cls._cached_directory is None: if cls._cached_directory is None:
parent_dir = pathlib.Path(__file__).parent.absolute()
try: try:
binary_directory = os.path.dirname(os.path.realpath(__main__.__file__)) binary_directory = os.path.dirname(os.path.realpath(__main__.__file__))
except AttributeError: except AttributeError:
...@@ -72,7 +74,11 @@ class Resources(object): ...@@ -72,7 +74,11 @@ class Resources(object):
application_directory = os.path.dirname(binary_directory) application_directory = os.path.dirname(binary_directory)
else: else:
application_directory = binary_directory application_directory = binary_directory
if os.path.exists(os.path.join(application_directory, 'resources', 'blink.ui')): unit_test_dir = '%s/../../../../resources' % parent_dir
if os.path.exists(os.path.join(unit_test_dir, 'blink.ui')):
# this is to make happy the self unit-testing, there must be a better way -adi
cls._cached_directory = unit_test_dir
elif os.path.exists(os.path.join(application_directory, 'resources', 'blink.ui')):
cls._cached_directory = os.path.join(application_directory, 'resources') cls._cached_directory = os.path.join(application_directory, 'resources')
else: else:
cls._cached_directory = os.path.join(application_directory, 'share', 'blink') cls._cached_directory = os.path.join(application_directory, 'share', 'blink')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment