D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
plesk
/
python
/
3
/
lib
/
python3.10
/
site-packages
/
imapclient
/
test
/
Filename :
util.py
back
Copy
# Copyright (c) 2014, Menno Smits # Released subject to the New BSD License # Please see http://en.wikipedia.org/wiki/BSD_licenses from __future__ import unicode_literals def find_unittest2(): import unittest if hasattr(unittest, 'skip') and hasattr(unittest, 'loader'): return unittest # unittest from stdlib is unittest2, use that try: import unittest2 # try for a separately installed unittest2 package except ImportError: raise ImportError( 'unittest2 not installed and unittest in standard library is not unittest2') else: return unittest2 unittest = find_unittest2() def patch_TestCase(): TestCase = unittest.TestCase # Older versions of unittest2 don't have # TestCase.assertRaisesRegex and newer version raises warnings # when you use assertRaisesRegexp. This helps deal with the # mismatch. if not hasattr(TestCase, 'assertRaisesRegex'): TestCase.assertRaisesRegex = TestCase.assertRaisesRegexp patch_TestCase()