def assertOldResultWarning(self, test, failures):
     with catch_warnings(record=True) as log:
         result = OldTestResult()
         test.run(result)
         self.assertEqual(len(result.failures), failures)
         warning, = log
         self.assertIs(warning.category, DeprecationWarning)
 def assertOldResultWarning(self, test, failures):
     with catch_warnings(record=True) as log:
         result = OldTestResult()
         test.run(result)
         self.assertEqual(len(result.failures), failures)
         warning, = log
         self.assertIs(warning.category, DeprecationWarning)
 def test_assert_dict_unicode_error(self):
     with catch_warnings(record=True):
         # This causes a UnicodeWarning due to its craziness
         one = ''.join(chr(i) for i in range(255))
         # this used to cause a UnicodeDecodeError constructing the failure msg
         with self.assertRaises(self.failureException):
             self.assertDictContainsSubset({'foo': one}, {'foo': u'\uFFFD'})
 def test_formatMessage_unicode_error(self):
     def run(cm):
         # This causes a UnicodeWarning due to its craziness
         one = ''.join([chr(i) for i in range(255)])
         # this used to cause a UnicodeDecodeError constructing msg
         self._formatMessage(one, u'\uFFFD')        
     cm = catch_warnings(record=True)
     self.runContext(cm, run)
 def assertOldResultWarning(self, test, failures):
     def run(log):
         result = OldTestResult()
         test.run(result)
         self.assertEqual(len(result.failures), failures)
         warning, = log
         self.assertIs(warning.category, DeprecationWarning)
     cm = catch_warnings(record=True)
     self.runContext(cm, run)
 def testAssertDictContainsSubset_UnicodeVsStrValues(self):
     def run(cm):
         one = ''.join([chr(i) for i in range(255)])
         two = u'\uFFFD'
         # this used to cause a UnicodeDecodeError when the values were compared under python 2.3, under
         # python 2.6 it causes a UnicodeWarning so wrapping in catch_warnings context manager
         self.assertRaises(self.failureException, self.assertDictContainsSubset, {'foo': one}, {'foo': two})
     cm = catch_warnings(record=True)
     self.runContext(cm, run)
Exemple #7
0
    def test_formatMessage_unicode_error(self):
        def run(cm):
            # This causes a UnicodeWarning due to its craziness
            one = ''.join([chr(i) for i in range(255)])
            # this used to cause a UnicodeDecodeError constructing msg
            self._formatMessage(one, u'\uFFFD')

        cm = catch_warnings(record=True)
        self.runContext(cm, run)
 def test_assert_dict_unicode_error(self):
     def run(cm):
         # This causes a UnicodeWarning due to its craziness
         one = ''.join([chr(i) for i in range(255)])
         # this used to cause a UnicodeDecodeError constructing the failure msg
         ar_cm = self.assertRaises(self.failureException)
         innerrun =lambda x: self.assertDictContainsSubset({'foo': one}, {'foo': u'\uFFFD'})
         self.runContext(ar_cm, innerrun)
     cm = catch_warnings(record=True)
     self.runContext(cm, run)
Exemple #9
0
    def assertOldResultWarning(self, test, failures):
        def run(log):
            result = OldTestResult()
            test.run(result)
            self.assertEqual(len(result.failures), failures)
            warning, = log
            self.assertIs(warning.category, DeprecationWarning)

        cm = catch_warnings(record=True)
        self.runContext(cm, run)
Exemple #10
0
    def test_assert_dict_unicode_error(self):
        def run(cm):
            # This causes a UnicodeWarning due to its craziness
            one = ''.join([chr(i) for i in range(255)])
            # this used to cause a UnicodeDecodeError constructing the failure msg
            ar_cm = self.assertRaises(self.failureException)
            innerrun = lambda x: self.assertDictContainsSubset(
                {'foo': one}, {'foo': u'\uFFFD'})
            self.runContext(ar_cm, innerrun)

        cm = catch_warnings(record=True)
        self.runContext(cm, run)
Exemple #11
0
    def testAssertDictContainsSubset_UnicodeVsStrValues(self):
        def run(cm):
            one = ''.join([chr(i) for i in range(255)])
            two = u'\uFFFD'
            # this used to cause a UnicodeDecodeError when the values were compared under python 2.3, under
            # python 2.6 it causes a UnicodeWarning so wrapping in catch_warnings context manager
            self.assertRaises(self.failureException,
                              self.assertDictContainsSubset, {'foo': one},
                              {'foo': two})

        cm = catch_warnings(record=True)
        self.runContext(cm, run)
    def testPendingDeprecationMethodNames(self):
        """Test fail* methods pending deprecation, they will warn in 3.2.

        Do not use these methods.  They will go away in 3.3.
        """
        with catch_warnings(record=True):
            self.failIfEqual(3, 5)
            self.failUnlessEqual(3, 3)
            self.failUnlessAlmostEqual(2.0, 2.0)
            self.failIfAlmostEqual(3.0, 5.0)
            self.failUnless(True)
            self.failUnlessRaises(TypeError, lambda _: 3.14 + u'spam')
            self.failIf(False)
    def testPendingDeprecationMethodNames(self):
        """Test fail* methods pending deprecation, they will warn in 3.2.

        Do not use these methods.  They will go away in 3.3.
        """
        with catch_warnings(record=True):
            self.failIfEqual(3, 5)
            self.failUnlessEqual(3, 3)
            self.failUnlessAlmostEqual(2.0, 2.0)
            self.failIfAlmostEqual(3.0, 5.0)
            self.failUnless(True)
            self.failUnlessRaises(TypeError, lambda _: 3.14 + u'spam')
            self.failIf(False)
 def test_formatMessage_unicode_error(self):
     with catch_warnings(record=True):
         # This causes a UnicodeWarning due to its craziness
         one = ''.join(chr(i) for i in range(255))
         # this used to cause a UnicodeDecodeError constructing msg
         self._formatMessage(one, u'\uFFFD')
 def test_formatMessage_unicode_error(self):
     with catch_warnings(record=True):
         # This causes a UnicodeWarning due to its craziness
         one = ''.join(chr(i) for i in range(255))
         # this used to cause a UnicodeDecodeError constructing msg
         self._formatMessage(one, u'\uFFFD')