mirror of
https://github.com/onionshare/onionshare.git
synced 2025-02-10 19:58:52 -05:00
Make helpers.get_pyinstaller_resource_path work when package is not frozen, and make tests report real platform to get accurate paths
This commit is contained in:
parent
ef5665b050
commit
e8ce6b1c54
@ -36,13 +36,16 @@ def get_pyinstaller_resource_path(filename):
|
|||||||
"""
|
"""
|
||||||
Returns the path a resource file in a frozen PyInstall app
|
Returns the path a resource file in a frozen PyInstall app
|
||||||
"""
|
"""
|
||||||
# Resource path from frozen PyInstaller app
|
# Check if app is "frozen" with pyinstaller
|
||||||
# https://pythonhosted.org/PyInstaller/#run-time-information
|
# https://pythonhosted.org/PyInstaller/#run-time-information
|
||||||
|
if getattr(sys, 'frozen', False):
|
||||||
p = get_platform()
|
p = get_platform()
|
||||||
if p == 'Darwin':
|
if p == 'Darwin':
|
||||||
return os.path.join(os.path.join(os.path.dirname(sys._MEIPASS), 'Resources'), filename)
|
return os.path.join(os.path.join(os.path.dirname(sys._MEIPASS), 'Resources'), filename)
|
||||||
elif p == 'Windows':
|
elif p == 'Windows':
|
||||||
return os.path.join(sys._MEIPASS, filename)
|
return os.path.join(sys._MEIPASS, filename)
|
||||||
|
else:
|
||||||
|
return os.path.join(os.path.dirname(os.path.dirname(__file__)), filename)
|
||||||
|
|
||||||
def get_html_path(filename):
|
def get_html_path(filename):
|
||||||
"""
|
"""
|
||||||
|
@ -23,5 +23,7 @@ import test_helpers
|
|||||||
|
|
||||||
def test_get_platform_returns_platform_system():
|
def test_get_platform_returns_platform_system():
|
||||||
"""get_platform() returns platform.system() when ONIONSHARE_PLATFORM is not defined"""
|
"""get_platform() returns platform.system() when ONIONSHARE_PLATFORM is not defined"""
|
||||||
|
p = helpers.platform.system
|
||||||
helpers.platform.system = lambda: 'Sega Saturn'
|
helpers.platform.system = lambda: 'Sega Saturn'
|
||||||
assert helpers.get_platform() == 'Sega Saturn'
|
assert helpers.get_platform() == 'Sega Saturn'
|
||||||
|
helpers.platform.system = p
|
||||||
|
Loading…
x
Reference in New Issue
Block a user