releasetools: Add a common base class for unittests.
All the releasetools unittests extend the common base class of test_utils.ReleaseToolsTestCase. Define tearDown() in the base class to do the clean-up works. Test: `pylint --rcfile=pylintrc test_*.py` Test: `python -m unittest discover .` Change-Id: I51775d964ef032dcdf3bb89c55e1a31371cde708
This commit is contained in:
@@ -19,7 +19,6 @@ import os
|
||||
import subprocess
|
||||
import tempfile
|
||||
import time
|
||||
import unittest
|
||||
import zipfile
|
||||
from hashlib import sha1
|
||||
|
||||
@@ -44,7 +43,8 @@ def get_2gb_string():
|
||||
yield '\0' * (step_size - block_size)
|
||||
|
||||
|
||||
class CommonZipTest(unittest.TestCase):
|
||||
class CommonZipTest(test_utils.ReleaseToolsTestCase):
|
||||
|
||||
def _verify(self, zip_file, zip_file_name, arcname, expected_hash,
|
||||
test_file_name=None, expected_stat=None, expected_mode=0o644,
|
||||
expected_compress_type=zipfile.ZIP_STORED):
|
||||
@@ -359,7 +359,7 @@ class CommonZipTest(unittest.TestCase):
|
||||
os.remove(zip_file.name)
|
||||
|
||||
|
||||
class CommonApkUtilsTest(unittest.TestCase):
|
||||
class CommonApkUtilsTest(test_utils.ReleaseToolsTestCase):
|
||||
"""Tests the APK utils related functions."""
|
||||
|
||||
APKCERTS_TXT1 = (
|
||||
@@ -407,9 +407,6 @@ class CommonApkUtilsTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.testdata_dir = test_utils.get_testdata_dir()
|
||||
|
||||
def tearDown(self):
|
||||
common.Cleanup()
|
||||
|
||||
@staticmethod
|
||||
def _write_apkcerts_txt(apkcerts_txt, additional=None):
|
||||
if additional is None:
|
||||
@@ -523,14 +520,11 @@ class CommonApkUtilsTest(unittest.TestCase):
|
||||
{})
|
||||
|
||||
|
||||
class CommonUtilsTest(unittest.TestCase):
|
||||
class CommonUtilsTest(test_utils.ReleaseToolsTestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.testdata_dir = test_utils.get_testdata_dir()
|
||||
|
||||
def tearDown(self):
|
||||
common.Cleanup()
|
||||
|
||||
def test_GetSparseImage_emptyBlockMapFile(self):
|
||||
target_files = common.MakeTempFile(prefix='target_files-', suffix='.zip')
|
||||
with zipfile.ZipFile(target_files, 'w') as target_files_zip:
|
||||
@@ -935,7 +929,7 @@ class CommonUtilsTest(unittest.TestCase):
|
||||
AssertionError, common.LoadInfoDict, target_files_zip, True)
|
||||
|
||||
|
||||
class InstallRecoveryScriptFormatTest(unittest.TestCase):
|
||||
class InstallRecoveryScriptFormatTest(test_utils.ReleaseToolsTestCase):
|
||||
"""Checks the format of install-recovery.sh.
|
||||
|
||||
Its format should match between common.py and validate_target_files.py.
|
||||
@@ -994,6 +988,3 @@ class InstallRecoveryScriptFormatTest(unittest.TestCase):
|
||||
recovery_image, boot_image, self._info)
|
||||
validate_target_files.ValidateInstallRecoveryScript(self._tempdir,
|
||||
self._info)
|
||||
|
||||
def tearDown(self):
|
||||
common.Cleanup()
|
||||
|
Reference in New Issue
Block a user