From c14a2d824557b06fd20bac77ddfc9e09001e2a92 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Fri, 9 Mar 2012 09:41:16 -0500 Subject: Use nose tools to check for exceptions Some of our tests checked for exceptions using an error-prone try block: they allowed the expected exception to pass, but sometimes forgot an else block, so the test passed when an exception wasn't thrown. This changes the tests to use the appropriate nose tools (raises, assert_raises). For consistency, tests that had a correct else block are also changed. Also fix some test problems that were hidden by the above: - in some sudorule and HBAC tests, change the *_add_user argument name from `users` to `user` - don't remove HBAC testing data while it was still used --- tests/test_install/test_updates.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'tests/test_install') diff --git a/tests/test_install/test_updates.py b/tests/test_install/test_updates.py index eb376f191..8b9ac28eb 100644 --- a/tests/test_install/test_updates.py +++ b/tests/test_install/test_updates.py @@ -24,7 +24,8 @@ import os import sys import ldap import nose -from tests.util import raises, PluginTester +from nose.tools import raises +from tests.util import PluginTester from tests.data import unicode_str from ipalib import api from ipalib import errors @@ -182,20 +183,16 @@ class test_update(object): assert(modified == True) + @raises(BadSyntax) def test_8_badsyntax(self): """ Test the updater with an unknown keyword """ - try: - modified = self.updater.update([self.testdir + "8_badsyntax.update"]) - except BadSyntax: - pass + modified = self.updater.update([self.testdir + "8_badsyntax.update"]) + @raises(BadSyntax) def test_9_badsyntax(self): """ Test the updater with an incomplete line """ - try: - modified = self.updater.update([self.testdir + "9_badsyntax.update"]) - except BadSyntax: - pass + modified = self.updater.update([self.testdir + "9_badsyntax.update"]) -- cgit