Пример #1
0
 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)
Пример #2
0
 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)
Пример #3
0
 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'})
Пример #4
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)
Пример #5
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)
Пример #6
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)
Пример #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)
Пример #8
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)
Пример #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)
Пример #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)
Пример #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)
Пример #12
0
    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)
Пример #13
0
    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)
Пример #14
0
 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')
Пример #15
0
 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')