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:
@@ -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"""
|
||||||
Run the emulation.
|
|
||||||
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:
|
|
||||||
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(self):
|
||||||
|
"""
|
||||||
|
Main function which run FS-UAE
|
||||||
|
"""
|
||||||
|
self._run_emulator()
|
||||||
|
|
||||||
def run(config_file, fs_uae_options, _):
|
def _run_emulator(self):
|
||||||
"""Run fs-uae with provided config file and options"""
|
"""execute fs-uae"""
|
||||||
return run_plain(config_file, fs_uae_options)
|
utils.run_command(['fs-uae'] + [self.conf_file] +
|
||||||
|
self.fsuae_options.list())
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
"""Do the cleanup. Here - just do nothing"""
|
||||||
|
return
|
||||||
|
|||||||
@@ -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())
|
||||||
|
|||||||
@@ -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')
|
||||||
|
|||||||
Reference in New Issue
Block a user