From 0e0dd2575bb2a1b6f6c5eba1f8cfb0d81cc1b091 Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Tue, 23 Dec 2014 15:19:03 +0000 Subject: oeqa/selftest: improve failure messages for devtool tests assertTrue prints "False is not True" if it fails, which is pretty much useless. Use a more appropriate assertion test where practical and add a message where it isn't. Signed-off-by: Paul Eggleton --- meta/lib/oeqa/selftest/devtool.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'meta/lib/oeqa/selftest/devtool.py') diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py index e8ff536c16..e158ad919f 100644 --- a/meta/lib/oeqa/selftest/devtool.py +++ b/meta/lib/oeqa/selftest/devtool.py @@ -25,15 +25,15 @@ class DevtoolTests(oeSelfTest): result = runCmd('devtool create-workspace %s' % tempdir) self.assertTrue(os.path.isfile(os.path.join(tempdir, 'conf', 'layer.conf'))) result = runCmd('bitbake-layers show-layers') - self.assertTrue(tempdir in result.output) + self.assertIn(tempdir, result.output) # Try creating a workspace layer with the default path self.track_for_cleanup(workspacedir) self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') result = runCmd('devtool create-workspace') self.assertTrue(os.path.isfile(os.path.join(workspacedir, 'conf', 'layer.conf'))) result = runCmd('bitbake-layers show-layers') - self.assertTrue(tempdir not in result.output) - self.assertTrue(workspacedir in result.output) + self.assertNotIn(tempdir, result.output) + self.assertIn(workspacedir, result.output) def test_recipetool_create(self): # Try adding a recipe @@ -74,7 +74,7 @@ class DevtoolTests(oeSelfTest): recipefile = os.path.join(tempdir, 'libmatchbox.bb') srcuri = 'git://git.yoctoproject.org/libmatchbox' result = runCmd('recipetool create -o %s %s -x %s' % (recipefile, srcuri, tempsrc)) - self.assertTrue(os.path.isfile(recipefile)) + self.assertTrue(os.path.isfile(recipefile), 'recipetool did not create recipe file; output:\n%s' % result.output) checkvars = {} checkvars['LICENSE'] = 'LGPLv2.1' checkvars['LIC_FILES_CHKSUM'] = 'file://COPYING;md5=7fbc338309ac38fefcd64b04bb903e34' @@ -111,7 +111,7 @@ class DevtoolTests(oeSelfTest): result = runCmd('wget %s' % url, cwd=tempdir) result = runCmd('tar xfv pv-1.5.3.tar.bz2', cwd=tempdir) srcdir = os.path.join(tempdir, 'pv-1.5.3') - self.assertTrue(os.path.isfile(os.path.join(srcdir, 'configure'))) + self.assertTrue(os.path.isfile(os.path.join(srcdir, 'configure')), 'Unable to find configure script in source directory') # Test devtool add self.track_for_cleanup(workspacedir) self.add_command_to_tearDown('bitbake -c cleansstate pv') @@ -127,9 +127,9 @@ class DevtoolTests(oeSelfTest): # Test devtool build result = runCmd('devtool build pv') installdir = get_bb_var('D', 'pv') - self.assertTrue(installdir) + self.assertTrue(installdir, 'Could not query installdir variable') bindir = get_bb_var('bindir', 'pv') - self.assertTrue(bindir) + self.assertTrue(bindir, 'Could not query bindir variable') if bindir[0] == '/': bindir = bindir[1:] self.assertTrue(os.path.isfile(os.path.join(installdir, bindir, 'pv')), 'pv binary not found in D') @@ -167,9 +167,9 @@ class DevtoolTests(oeSelfTest): result = runCmd("sed -i 's!^\.TH.*!.TH MDADM 8 \"\" v9.999-custom!' %s" % os.path.join(tempdir, 'mdadm.8.in')) bitbake('mdadm -c package') pkgd = get_bb_var('PKGD', 'mdadm') - self.assertTrue(pkgd) + self.assertTrue(pkgd, 'Could not query PKGD variable') mandir = get_bb_var('mandir', 'mdadm') - self.assertTrue(mandir) + self.assertTrue(mandir, 'Could not query mandir variable') if mandir[0] == '/': mandir = mandir[1:] with open(os.path.join(pkgd, mandir, 'man8', 'mdadm.8'), 'r') as f: @@ -223,7 +223,7 @@ class DevtoolTests(oeSelfTest): elif re.search('minicom_[^_]*.bb$', line): self.assertEqual(line[:3], ' M ', 'Unexpected status in line: %s' % line) else: - self.assertTrue(False, 'Unexpected modified file in status: %s' % line) + raise AssertionError('Unexpected modified file in status: %s' % line) def test_devtool_extract(self): # Check preconditions -- cgit 1.2.3-korg