From 7bb6e1375bbd63c3d099113fd1faaa2272279eff Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Fri, 12 Oct 2012 11:26:23 +0200 Subject: [PATCH] Replace custom algorithm in constants unittest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is no need for the β_IsUniqueSequenceβ function anymore, it can easily be replaced by utils.FindDuplicates. Also, pass the message as a keyword parameter and use the more commonly used assert* functions. Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- test/ganeti.constants_unittest.py | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/test/ganeti.constants_unittest.py b/test/ganeti.constants_unittest.py index 105a4d372..64f2a631b 100755 --- a/test/ganeti.constants_unittest.py +++ b/test/ganeti.constants_unittest.py @@ -131,25 +131,17 @@ class TestConfdConstants(unittest.TestCase): """Test the confd constants""" def testFourCc(self): - self.failUnlessEqual(len(constants.CONFD_MAGIC_FOURCC), 4, - "Invalid fourcc len, should be 4") - - def _IsUniqueSequence(self, sequence): - seen = set() - for member in sequence: - if member in seen: - return False - seen.add(member) - return True + self.assertEqual(len(constants.CONFD_MAGIC_FOURCC), 4, + msg="Invalid fourcc len, should be 4") def testReqs(self): - self.failUnless(self._IsUniqueSequence(constants.CONFD_REQS), - "Duplicated confd request code") + self.assertFalse(utils.FindDuplicates(constants.CONFD_REQS), + msg="Duplicated confd request code") def testReplStatuses(self): - self.failUnless(self._IsUniqueSequence(constants.CONFD_REPL_STATUSES), - "Duplicated confd reply status code") + self.assertFalse(utils.FindDuplicates(constants.CONFD_REPL_STATUSES), + msg="Duplicated confd reply status code") -if __name__ == '__main__': +if __name__ == "__main__": testutils.GanetiTestProgram() -- GitLab