mirror of
https://github.com/onionshare/onionshare.git
synced 2025-02-17 13:02:42 -05:00
Fix tests
This commit is contained in:
parent
60afaaf338
commit
c572ab996a
@ -122,8 +122,13 @@ class Settings(object):
|
||||
"""
|
||||
p = platform.system()
|
||||
if p == 'Windows':
|
||||
appdata = os.environ['APPDATA']
|
||||
return '{}\\OnionShare\\onionshare.json'.format(appdata)
|
||||
try:
|
||||
appdata = os.environ['APPDATA']
|
||||
return '{}\\OnionShare\\onionshare.json'.format(appdata)
|
||||
except:
|
||||
# If for some reason we don't have the 'APPDATA' environment variable
|
||||
# (like running tests in Linux while pretending to be in Windows)
|
||||
return os.path.expanduser('~/.config/onionshare/onionshare.json')
|
||||
elif p == 'Darwin':
|
||||
return os.path.expanduser('~/Library/Application Support/OnionShare/onionshare.json')
|
||||
else:
|
||||
|
@ -8,7 +8,7 @@ import tempfile
|
||||
|
||||
import pytest
|
||||
|
||||
from onionshare import common, web, settings
|
||||
from onionshare import common, web, settings, strings
|
||||
|
||||
@pytest.fixture
|
||||
def temp_dir_1024():
|
||||
@ -151,7 +151,10 @@ def time_strftime(monkeypatch):
|
||||
|
||||
@pytest.fixture
|
||||
def common_obj():
|
||||
return common.Common()
|
||||
_common = common.Common()
|
||||
_common.settings = settings.Settings(_common)
|
||||
strings.load_strings(_common)
|
||||
return _common
|
||||
|
||||
@pytest.fixture
|
||||
def settings_obj(sys_onionshare_dev_mode, platform_linux):
|
||||
|
@ -32,12 +32,6 @@ from onionshare import strings
|
||||
# return path
|
||||
# common.get_resource_path = get_resource_path
|
||||
|
||||
|
||||
def test_starts_with_empty_strings():
|
||||
""" Creates an empty strings dict by default """
|
||||
assert strings.strings == {}
|
||||
|
||||
|
||||
def test_underscore_is_function():
|
||||
assert callable(strings._) and isinstance(strings._, types.FunctionType)
|
||||
|
||||
@ -53,11 +47,13 @@ class TestLoadStrings:
|
||||
def test_load_strings_loads_other_languages(
|
||||
self, common_obj, locale_fr, sys_onionshare_dev_mode):
|
||||
""" load_strings() loads other languages in different locales """
|
||||
strings.load_strings(common_obj, "fr")
|
||||
common_obj.settings.set('locale', 'fr')
|
||||
strings.load_strings(common_obj)
|
||||
assert strings._('preparing_files') == "Préparation des fichiers à partager."
|
||||
|
||||
def test_load_invalid_locale(
|
||||
self, common_obj, locale_invalid, sys_onionshare_dev_mode):
|
||||
""" load_strings() raises a KeyError for an invalid locale """
|
||||
with pytest.raises(KeyError):
|
||||
strings.load_strings(common_obj, 'XX')
|
||||
common_obj.settings.set('locale', 'XX')
|
||||
strings.load_strings(common_obj)
|
||||
|
Loading…
x
Reference in New Issue
Block a user