[Python-checkins] python/dist/src/Lib/test test_pprint.py,1.10,1.11

fdrake@users.sourceforge.net fdrake@users.sourceforge.net
Mon, 30 Dec 2002 23:16:19 -0800


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv15729

Modified Files:
	test_pprint.py 
Log Message:
Make sure PrettyPrinter methods that mirror the module-level
convenience functions isreadable() and isrecursive() work the same way
as the convenience functions.


Index: test_pprint.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pprint.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** test_pprint.py	22 Aug 2002 19:45:32 -0000	1.10
--- test_pprint.py	31 Dec 2002 07:16:16 -0000	1.11
***************
*** 1,10 ****
  import pprint
  import unittest
- from test import test_support
  
  try:
      uni = unicode
  except NameError:
!     def uni(x):return x
  
  
--- 1,11 ----
  import pprint
+ import test.test_support
  import unittest
  
  try:
      uni = unicode
  except NameError:
!     def uni(x):
!         return x
  
  
***************
*** 19,28 ****
--- 20,36 ----
          # Verify .isrecursive() and .isreadable() w/o recursion
          verify = self.assert_
+         pp = pprint.PrettyPrinter()
          for safe in (2, 2.0, 2j, "abc", [3], (2,2), {3: 3}, uni("yaddayadda"),
                       self.a, self.b):
+             # module-level convenience functions
              verify(not pprint.isrecursive(safe),
                     "expected not isrecursive for " + `safe`)
              verify(pprint.isreadable(safe),
                     "expected isreadable for " + `safe`)
+             # PrettyPrinter methods
+             verify(not pp.isrecursive(safe),
+                    "expected not isrecursive for " + `safe`)
+             verify(pp.isreadable(safe),
+                    "expected isreadable for " + `safe`)
  
      def test_knotted(self):
***************
*** 35,42 ****
--- 43,53 ----
  
          verify = self.assert_
+         pp = pprint.PrettyPrinter()
  
          for icky in self.a, self.b, self.d, (self.d, self.d):
              verify(pprint.isrecursive(icky), "expected isrecursive")
              verify(not pprint.isreadable(icky),  "expected not isreadable")
+             verify(pp.isrecursive(icky), "expected isrecursive")
+             verify(not pp.isreadable(icky),  "expected not isreadable")
  
          # Break the cycles.
***************
*** 46,62 ****
--- 57,86 ----
  
          for safe in self.a, self.b, self.d, (self.d, self.d):
+             # module-level convenience functions
              verify(not pprint.isrecursive(safe),
                     "expected not isrecursive for " + `safe`)
              verify(pprint.isreadable(safe),
                     "expected isreadable for " + `safe`)
+             # PrettyPrinter methods
+             verify(not pp.isrecursive(safe),
+                    "expected not isrecursive for " + `safe`)
+             verify(pp.isreadable(safe),
+                    "expected isreadable for " + `safe`)
  
      def test_unreadable(self):
          # Not recursive but not readable anyway
          verify = self.assert_
+         pp = pprint.PrettyPrinter()
          for unreadable in type(3), pprint, pprint.isrecursive:
+             # module-level convenience functions
              verify(not pprint.isrecursive(unreadable),
                     "expected not isrecursive for " + `unreadable`)
              verify(not pprint.isreadable(unreadable),
                     "expected not isreadable for " + `unreadable`)
+             # PrettyPrinter methods
+             verify(not pp.isrecursive(unreadable),
+                    "expected not isrecursive for " + `unreadable`)
+             verify(not pp.isreadable(unreadable),
+                    "expected not isreadable for " + `unreadable`)
  
      def test_same_as_repr(self):
***************
*** 119,123 ****
  
  def test_main():
!     test_support.run_unittest(QueryTestCase)
  
  
--- 143,147 ----
  
  def test_main():
!     test.test_support.run_unittest(QueryTestCase)