I put some python code comments inline, I am not sure about the approach to test the python object and the executable in two different code paths. I think it would be preferable to convert the call_upgrader_object to use the in-tree binary to avoid having two code paths. Once the code calls a external executable (the bin/ubuntu-core-upgrader from this source tree) it will be trivial to convert to call a different one once the need arises (i.e. once there is a external one that needs testing).
So instead of call_upgrader_{object,command} maybe something like:
"""
def call_upgrader(command_file, root_dir):
pyroot = os.path.normpath(os.path.join(os.path.dirname(__file__), ".."))
env = copy.copy(os.environ)
env["PYTHONPATH"] = pyroot
subprocess.check_call( [os.path.join(pyroot, "bin", "ubuntu-core-upgrade"), '--root-dir', root_dir,
'--debug', '1',
# don't delete the archive and command files.
# The tests clean up after themselves so they will get removed then,
# but useful to have them around to diagnose test failures. '--leave-files', command_file],
env=env)
"""
I put some python code comments inline, I am not sure about the approach to test the python object and the executable in two different code paths. I think it would be preferable to convert the call_upgrader_ object to use the in-tree binary to avoid having two code paths. Once the code calls a external executable (the bin/ubuntu- core-upgrader from this source tree) it will be trivial to convert to call a different one once the need arises (i.e. once there is a external one that needs testing).
So instead of call_upgrader_ {object, command} maybe something like: command_ file, root_dir): normpath( os.path. join(os. path.dirname( __file_ _), "..")) os.environ) "PYTHONPATH" ] = pyroot check_call(
[os.path. join(pyroot, "bin", "ubuntu- core-upgrade" ),
'--root- dir', root_dir,
'--leave- files',
command_ file],
"""
def call_upgrader(
pyroot = os.path.
env = copy.copy(
env[
subprocess.
'--debug', '1',
# don't delete the archive and command files.
# The tests clean up after themselves so they will get removed then,
# but useful to have them around to diagnose test failures.
env=env)
"""