qubes-installer-qubes-os/anaconda/old_tests/pyanaconda_test/iutil_test.py
Marek Marczykowski-Górecki f73b3741f0 Update anaconda to 20.25.16
Apply result of "git diff anaconda-18.37.11-1..anaconda-20.25.16-1" and
resolve conflicts.
2014-04-08 05:50:31 +02:00

38 lines
1.2 KiB
Python

import mock
import sys
class IutilTest(mock.TestCase):
def setUp(self):
self.setupModules(
['_isys', 'logging', 'pyanaconda.anaconda_log', 'block'])
import pyanaconda
pyanaconda.anaconda_log = mock.Mock()
def tearDown(self):
self.tearDownModules()
def copy_to_sysimage_test(self):
from pyanaconda import iutil
fs = mock.DiskIO()
self.take_over_io(fs, iutil)
self.assertEqual(iutil.copy_to_sysimage("/etc/securetty"), False)
fs["/etc/securetty"] = "tty1"
iutil.os.makedirs = mock.Mock()
iutil.shutil.copy = mock.Mock()
self.assertEqual(iutil.copy_to_sysimage("/etc/securetty"), True)
iutil.os.makedirs.assert_called_with("/mnt/sysimage/etc")
iutil.shutil.copy.assert_called_with("/etc/securetty",
"/mnt/sysimage/etc/securetty")
def testExecCaptureNonZeroFatal (self):
import iutil
try:
argv = ["-c", "import sys; sys.exit(3);"]
iutil.execWithCapture(sys.executable, argv, root=None, fatal=True)
except RuntimeError, ex:
self.assertIn("return code: 3", str(ex))
else:
self.fail("RuntimeError not raised")