[Python-checkins] python/dist/src/Lib/test test_sets.py,1.11,1.12
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Sun, 25 Aug 2002 11:21:49 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv21692/python/lib/test
Modified Files:
test_sets.py
Log Message:
TestSubset(): Generalized the framework to support testing upcoming
<, <=, etc methods too.
Index: test_sets.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sets.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** test_sets.py 25 Aug 2002 18:02:29 -0000 1.11
--- test_sets.py 25 Aug 2002 18:21:47 -0000 1.12
***************
*** 362,371 ****
class TestSubsets(unittest.TestCase):
def test_issubset(self):
! result = self.left.issubset(self.right)
! if "<" in self.cases:
! self.failUnless(result)
! else:
! self.failUnless(not result)
#------------------------------------------------------------------------------
--- 362,384 ----
class TestSubsets(unittest.TestCase):
+ case2method = {"<=": "issubset",
+ ">=": "issuperset",
+ }
+ cases_with_ops = Set(["==", "!="])
+
def test_issubset(self):
! x = self.left
! y = self.right
! for case in "!=", "==", "<", "<=", ">", ">=":
! expected = case in self.cases
! if case in TestSubsets.case2method:
! # Test the method-name spelling.
! method = getattr(x, TestSubsets.case2method[case])
! result = method(y)
! self.assertEqual(result, expected)
! if case in TestSubsets.cases_with_ops:
! # Test the binary infix spelling.
! result = eval("x" + case + "y", locals())
! self.assertEqual(result, expected)
#------------------------------------------------------------------------------
***************
*** 375,379 ****
right = Set()
name = "both empty"
! cases = "<>"
#------------------------------------------------------------------------------
--- 388,392 ----
right = Set()
name = "both empty"
! cases = "==", "<=", ">="
#------------------------------------------------------------------------------
***************
*** 383,387 ****
right = Set([1, 2])
name = "equal pair"
! cases = "<>"
#------------------------------------------------------------------------------
--- 396,400 ----
right = Set([1, 2])
name = "equal pair"
! cases = "==", "<=", ">="
#------------------------------------------------------------------------------
***************
*** 391,395 ****
right = Set([1, 2])
name = "one empty, one non-empty"
! cases = "<"
#------------------------------------------------------------------------------
--- 404,408 ----
right = Set([1, 2])
name = "one empty, one non-empty"
! cases = "!=", "<", "<="
#------------------------------------------------------------------------------
***************
*** 399,403 ****
right = Set([1, 2])
name = "one a non-empty subset of other"
! cases = "<"
#------------------------------------------------------------------------------
--- 412,416 ----
right = Set([1, 2])
name = "one a non-empty subset of other"
! cases = "!=", "<", "<="
#------------------------------------------------------------------------------
***************
*** 407,411 ****
right = Set([2])
name = "neither empty, neither contains"
! cases = ""
#==============================================================================
--- 420,424 ----
right = Set([2])
name = "neither empty, neither contains"
! cases = "!="
#==============================================================================