test: remove unittest dependency for OSBuild
Remove the dependency on unittest for the `OSBuild` class which used the `unittest` instance only for `assertEqual`, which can easily also be done via a plain `assert`.
This commit is contained in:
parent
aa00e62fed
commit
a47a40cf26
6 changed files with 10 additions and 11 deletions
|
|
@ -25,7 +25,7 @@ class TestAssemblers(test.TestBase):
|
|||
super().setUpClass()
|
||||
|
||||
def setUp(self):
|
||||
self.osbuild = test.OSBuild(self)
|
||||
self.osbuild = test.OSBuild()
|
||||
|
||||
@contextlib.contextmanager
|
||||
def run_assembler(self, osb, name, options, output_path):
|
||||
|
|
@ -223,7 +223,7 @@ class TestAssemblers(test.TestBase):
|
|||
options,
|
||||
filename) as (tree, image):
|
||||
output = subprocess.check_output(["file", "--mime-type", image], encoding="utf-8")
|
||||
_, mimetype = output.strip().split(": ") # "filename: mimetype"
|
||||
_, mimetype = output.strip().split(": ") # "filename: mimetype"
|
||||
self.assertIn(mimetype, expected_mimetypes)
|
||||
|
||||
if compression:
|
||||
|
|
@ -245,6 +245,7 @@ class TestAssemblers(test.TestBase):
|
|||
self.assertEqual(diff["deleted_files"], [])
|
||||
self.assertEqual(diff["differences"], {})
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def loop_create_device(ctl, fd, offset=None, sizelimit=None):
|
||||
while True:
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ from .. import test
|
|||
@unittest.skipUnless(test.TestBase.can_bind_mount(), "root-only")
|
||||
class TestBoot(test.TestBase):
|
||||
def setUp(self):
|
||||
self.osbuild = test.OSBuild(self)
|
||||
self.osbuild = test.OSBuild()
|
||||
|
||||
def test_boot(self):
|
||||
#
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ from .. import test
|
|||
|
||||
class TestExecutable(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.osbuild = test.OSBuild(self)
|
||||
self.osbuild = test.OSBuild()
|
||||
|
||||
def test_invalid_manifest(self):
|
||||
invalid = json.dumps({"foo": 42})
|
||||
|
|
|
|||
|
|
@ -33,9 +33,10 @@ NOOP_V2 = {
|
|||
]
|
||||
}
|
||||
|
||||
|
||||
class TestNoop(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.osbuild = test.OSBuild(self)
|
||||
self.osbuild = test.OSBuild()
|
||||
|
||||
def test_noop(self):
|
||||
#
|
||||
|
|
@ -55,7 +56,6 @@ class TestNoop(unittest.TestCase):
|
|||
osb.compile("{}")
|
||||
osb.compile("{}")
|
||||
|
||||
|
||||
def test_noop_v2(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
with self.osbuild as osb:
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ class TestStages(test.TestBase):
|
|||
shutil.rmtree(cls.store)
|
||||
|
||||
def setUp(self):
|
||||
self.osbuild = test.OSBuild(self, cache_from=self.store)
|
||||
self.osbuild = test.OSBuild(cache_from=self.store)
|
||||
|
||||
def run_stage_diff_test(self, test_dir: str):
|
||||
with self.osbuild as osb:
|
||||
|
|
|
|||
|
|
@ -217,14 +217,12 @@ class OSBuild(contextlib.AbstractContextManager):
|
|||
when exiting.
|
||||
"""
|
||||
|
||||
_unittest = None
|
||||
_cache_from = None
|
||||
|
||||
_exitstack = None
|
||||
_cachedir = None
|
||||
|
||||
def __init__(self, unit_test, cache_from=None):
|
||||
self._unittest = unit_test
|
||||
def __init__(self, *, cache_from=None):
|
||||
self._cache_from = cache_from
|
||||
|
||||
def __enter__(self):
|
||||
|
|
@ -331,7 +329,7 @@ class OSBuild(contextlib.AbstractContextManager):
|
|||
if check:
|
||||
raise subprocess.CalledProcessError(p.returncode, cmd_args, data_stdout, data_stderr)
|
||||
self._print_result(p.returncode, data_stdout, data_stderr)
|
||||
self._unittest.assertEqual(p.returncode, 0)
|
||||
assert p.returncode == 0
|
||||
|
||||
return json.loads(data_stdout)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue