mirror of
https://github.com/gryf/fs-uae-wrapper.git
synced 2026-03-25 14:13:35 +01:00
Compare commits
3 Commits
0.8.1
...
b015e443eb
| Author | SHA1 | Date | |
|---|---|---|---|
| b015e443eb | |||
| 874213aef9 | |||
| 1559591417 |
@@ -2,7 +2,10 @@ language: python
|
||||
env:
|
||||
- TOXENV=py27
|
||||
- TOXENV=py27-flake8
|
||||
- TOXENV=py34
|
||||
- TOXENV=py34-flake8
|
||||
- TOXENV=py3
|
||||
- TOXENV=py3-flake8
|
||||
install: pip install tox
|
||||
script: tox
|
||||
before_install:
|
||||
- sudo apt-get update
|
||||
- sudo apt-get install -y python-tk python3-tk
|
||||
|
||||
@@ -219,7 +219,11 @@ class Base(object):
|
||||
changed_options[key] = abspath
|
||||
continue
|
||||
|
||||
changed_options[key] = os.path.abspath(val)
|
||||
_val = os.path.abspath(val)
|
||||
if os.path.exists(_val):
|
||||
changed_options[key] = _val
|
||||
else:
|
||||
changed_options[key] = val
|
||||
|
||||
self.fsuae_options.update(changed_options)
|
||||
|
||||
|
||||
@@ -144,6 +144,7 @@ def interpolate_variables(string, config_path, base=None):
|
||||
- $BASE
|
||||
"""
|
||||
|
||||
_string = string
|
||||
if '$CONFIG' in string:
|
||||
conf_path = os.path.dirname(os.path.abspath(config_path))
|
||||
string = os.path.abspath(string.replace('$CONFIG', conf_path))
|
||||
@@ -166,7 +167,9 @@ def interpolate_variables(string, config_path, base=None):
|
||||
if '$BASE' in string:
|
||||
string = string.replace('$BASE', base)
|
||||
|
||||
return string
|
||||
if os.path.exists(string):
|
||||
return string
|
||||
return _string
|
||||
|
||||
|
||||
def get_config(conf_file):
|
||||
|
||||
@@ -47,9 +47,11 @@ class TestBase(TestCase):
|
||||
bobj.clean()
|
||||
self.assertFalse(os.path.exists(self.dirname))
|
||||
|
||||
@mock.patch('os.path.exists')
|
||||
@mock.patch('fs_uae_wrapper.utils.get_config')
|
||||
def test_normalize_options(self, get_config):
|
||||
def test_normalize_options(self, get_config, os_exists):
|
||||
|
||||
os_exists.return_value = True
|
||||
bobj = base.Base('Config.fs-uae', utils.CmdOption(), {})
|
||||
|
||||
get_config.return_value = {'kickstarts_dir': '/some/path'}
|
||||
@@ -92,6 +94,28 @@ class TestBase(TestCase):
|
||||
bobj._normalize_options()
|
||||
self.assertDictEqual(bobj.fsuae_options, {})
|
||||
|
||||
@mock.patch('os.path.exists')
|
||||
@mock.patch('fs_uae_wrapper.utils.get_config')
|
||||
def test_normalize_options_path_not_exists(self, get_config, os_exists):
|
||||
|
||||
os_exists.return_value = False
|
||||
bobj = base.Base('Config.fs-uae', utils.CmdOption(), {})
|
||||
|
||||
get_config.return_value = {'kickstarts_dir': '/some/path'}
|
||||
bobj._normalize_options()
|
||||
self.assertDictEqual(bobj.fsuae_options, {})
|
||||
|
||||
os.chdir(self.dirname)
|
||||
get_config.return_value = {'fmv_rom': 'bar'}
|
||||
bobj._normalize_options()
|
||||
self.assertDictEqual(bobj.fsuae_options, {'fmv_rom': 'bar'})
|
||||
|
||||
get_config.return_value = {'floppies_dir': '../some/path'}
|
||||
bobj.fsuae_options = utils.CmdOption()
|
||||
bobj._normalize_options()
|
||||
self.assertDictEqual(bobj.fsuae_options,
|
||||
{'floppies_dir': '../some/path'})
|
||||
|
||||
def test_set_assets_paths(self):
|
||||
|
||||
bobj = base.Base('Config.fs-uae', utils.CmdOption(), {})
|
||||
|
||||
@@ -234,11 +234,13 @@ class TestCmdOptions(TestCase):
|
||||
self.assertListEqual(sorted(cmd.list()),
|
||||
['--fast_memory=4096', '--fullscreen'])
|
||||
|
||||
@mock.patch('os.path.exists')
|
||||
@mock.patch('os.getenv')
|
||||
@mock.patch('os.path.expandvars')
|
||||
@mock.patch('distutils.spawn.find_executable')
|
||||
def test_interpolate_variables(self, find_exe, expandv, getenv):
|
||||
def test_interpolate_variables(self, find_exe, expandv, getenv, os_exists):
|
||||
|
||||
os_exists.return_value = True
|
||||
itrpl = utils.interpolate_variables
|
||||
|
||||
string = '$CONFIG/../path/to/smth'
|
||||
@@ -264,3 +266,11 @@ class TestCmdOptions(TestCase):
|
||||
'$BASE')
|
||||
self.assertEqual(itrpl(string, '/home/user/Config.fs-uae', 'base'),
|
||||
'base')
|
||||
|
||||
@mock.patch('os.getenv')
|
||||
@mock.patch('os.path.expandvars')
|
||||
def test_interpolate_variables_path_not_exists(self, expandv, getenv):
|
||||
itrpl = utils.interpolate_variables
|
||||
|
||||
string = '$CONFIG/../path/to/smth'
|
||||
self.assertEqual(itrpl(string, '/home/user/Config.fs-uae'), string)
|
||||
|
||||
6
tox.ini
6
tox.ini
@@ -1,5 +1,5 @@
|
||||
[tox]
|
||||
envlist = py27,py34,py27-flake8,py34-flake8
|
||||
envlist = py27,py3,py27-flake8,py3-flake8
|
||||
|
||||
usedevelop = True
|
||||
|
||||
@@ -14,8 +14,8 @@ deps = -r{toxinidir}/test-requirements.txt
|
||||
deps = {[testenv]deps}
|
||||
mock
|
||||
|
||||
[testenv:py34-flake8]
|
||||
basepython = python3.4
|
||||
[testenv:py3-flake8]
|
||||
basepython = python3
|
||||
deps = flake8
|
||||
commands = flake8 {posargs}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user