1
0
mirror of https://github.com/gryf/fs-uae-wrapper.git synced 2025-12-19 12:28:12 +01:00

Make plain wrapper module use base.Base class

This commit is contained in:
2017-01-08 11:21:43 +01:00
parent a14871c52f
commit 8a6ddda7c8
3 changed files with 26 additions and 22 deletions

View File

@@ -4,24 +4,24 @@
Simple class for executing fs-uae with specified parameters. This is a Simple class for executing fs-uae with specified parameters. This is a
failsafe class for running fs-uae. failsafe class for running fs-uae.
""" """
import subprocess from fs_uae_wrapper import base
import sys from fs_uae_wrapper import utils
def run_plain(conf_file, fs_uae_options): class Wrapper(base.Base):
"""Simple class for running fs-uae"""
def run(self):
""" """
Run the emulation. Main function which run FS-UAE
conf_file is a path to the configuration,
fs_uae_options is an dict-like object which contains commandline options to
be passed to fs-uae
""" """
try: self._run_emulator()
subprocess.call(['fs-uae'] + [conf_file] + fs_uae_options.list())
except subprocess.CalledProcessError:
sys.stderr.write('Warning: fs-uae returned non 0 exit code\n')
return True
def _run_emulator(self):
"""execute fs-uae"""
utils.run_command(['fs-uae'] + [self.conf_file] +
self.fsuae_options.list())
def run(config_file, fs_uae_options, _): def clean(self):
"""Run fs-uae with provided config file and options""" """Do the cleanup. Here - just do nothing"""
return run_plain(config_file, fs_uae_options) return

View File

@@ -11,8 +11,12 @@ from fs_uae_wrapper import utils
class TestPlainModule(TestCase): class TestPlainModule(TestCase):
@mock.patch('subprocess.call') @mock.patch('fs_uae_wrapper.utils.run_command')
def test_show(self, subprocess_call): def test_run(self, run_command):
wrapper = plain.Wrapper('some.conf', utils.CmdOption(), {})
wrapper.run()
run_command.assert_called_once_with(['fs-uae', 'some.conf'])
plain.run('some.conf', utils.CmdOption(), None) def test_clean(self):
subprocess_call.assert_called_once() wrapper = plain.Wrapper('some.conf', utils.CmdOption(), {})
self.assertIsNone(wrapper.clean())

View File

@@ -28,7 +28,7 @@ class TestWrapper(TestCase):
os.unlink(self.fname) os.unlink(self.fname)
sys.argv = self._argv[:] sys.argv = self._argv[:]
@mock.patch('fs_uae_wrapper.plain.run') @mock.patch('fs_uae_wrapper.plain.Wrapper.run')
def test_run(self, mock_plain_run): def test_run(self, mock_plain_run):
sys.argv.append('--help') sys.argv.append('--help')