Python test.test_support.unload() Examples

The following are 30 code examples of test.test_support.unload(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module test.test_support , or try the search function .
Example #1
Source File: test_build_ext.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def tearDown(self):
        if self.xx_created:
            test_support.unload('xx')
            # XXX on Windows the test leaves a directory
            # with xx module in TEMP
        super(BuildExtTestCase, self).tearDown() 
Example #2
Source File: test_importhooks.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def testBlocker(self):
        mname = "exceptions"  # an arbitrary harmless builtin module
        test_support.unload(mname)
        sys.meta_path.append(ImportBlocker(mname))
        self.assertRaises(ImportError, __import__, mname) 
Example #3
Source File: test_future.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_future1(self):
        test_support.unload('test_future1')
        from test import test_future1
        self.assertEqual(test_future1.result, 6) 
Example #4
Source File: test_future.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_future2(self):
        test_support.unload('test_future2')
        from test import test_future2
        self.assertEqual(test_future2.result, 6) 
Example #5
Source File: test_future.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_future3(self):
        test_support.unload('test_future3')
        from test import test_future3 
Example #6
Source File: test_build_ext.py    From datafari with Apache License 2.0 5 votes vote down vote up
def tearDown(self):
        if self.xx_created:
            test_support.unload('xx')
            # XXX on Windows the test leaves a directory
            # with xx module in TEMP
        super(BuildExtTestCase, self).tearDown() 
Example #7
Source File: test_future.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def test_future1(self):
        test_support.unload('test_future1')
        from test import test_future1
        self.assertEqual(test_future1.result, 6) 
Example #8
Source File: test_future.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def test_future2(self):
        test_support.unload('test_future2')
        from test import test_future2
        self.assertEqual(test_future2.result, 6) 
Example #9
Source File: test_future.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def test_future3(self):
        test_support.unload('test_future3')
        from test import test_future3 
Example #10
Source File: test_build_ext.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def tearDown(self):
        if self.xx_created:
            test_support.unload('xx')
            # XXX on Windows the test leaves a directory
            # with xx module in TEMP
        super(BuildExtTestCase, self).tearDown() 
Example #11
Source File: regrtest.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def runtest_inner(test, verbose, quiet, huntrleaks=False):
    test_support.unload(test)
    if verbose:
        capture_stdout = None
    else:
        capture_stdout = StringIO.StringIO()

    test_time = 0.0
    refleak = False  # True if the test leaked references.
    try:
        save_stdout = sys.stdout
        try:
            if capture_stdout:
                sys.stdout = capture_stdout
            if test.startswith('test.'):
                abstest = test
            else:
                # Always import it from the test package
                abstest = 'test.' + test
            with saved_test_environment(test, verbose, quiet) as environment:
                start_time = time.time()
                the_package = __import__(abstest, globals(), locals(), [])
                the_module = getattr(the_package, test)
                # Old tests run to completion simply as a side-effect of
                # being imported.  For tests based on unittest or doctest,
                # explicitly invoke their test_main() function (if it exists).
                indirect_test = getattr(the_module, "test_main", None)
                if indirect_test is not None:
                    indirect_test()
                if huntrleaks:
                    refleak = dash_R(the_module, test, indirect_test,
                        huntrleaks)
                test_time = time.time() - start_time
        finally:
            sys.stdout = save_stdout
    except test_support.ResourceDenied, msg:
        if not quiet:
            print test, "skipped --", msg
            sys.stdout.flush()
        return RESOURCE_DENIED, test_time 
Example #12
Source File: test_future.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def test_future1(self):
        test_support.unload('test_future1')
        from test import test_future1
        self.assertEqual(test_future1.result, 6) 
Example #13
Source File: test_future.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def test_future2(self):
        test_support.unload('test_future2')
        from test import test_future2
        self.assertEqual(test_future2.result, 6) 
Example #14
Source File: test_future.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def test_future3(self):
        test_support.unload('test_future3')
        from test import test_future3 
Example #15
Source File: test_build_ext.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def tearDown(self):
        if self.xx_created:
            test_support.unload('xx')
            # XXX on Windows the test leaves a directory
            # with xx module in TEMP
        super(BuildExtTestCase, self).tearDown() 
Example #16
Source File: test_build_ext.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def tearDown(self):
        if self.xx_created:
            test_support.unload('xx')
            # XXX on Windows the test leaves a directory
            # with xx module in TEMP
        super(BuildExtTestCase, self).tearDown() 
Example #17
Source File: test_future.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_future1(self):
        test_support.unload('test_future1')
        from test import test_future1
        self.assertEqual(test_future1.result, 6) 
Example #18
Source File: test_future.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_future2(self):
        test_support.unload('test_future2')
        from test import test_future2
        self.assertEqual(test_future2.result, 6) 
Example #19
Source File: test_future.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_future3(self):
        test_support.unload('test_future3')
        from test import test_future3 
Example #20
Source File: test_build_ext.py    From Computable with MIT License 5 votes vote down vote up
def tearDown(self):
        # Get everything back to normal
        if os.path.exists(_XX_MODULE_PATH):
            test_support.unload('xx')
            sys.path[:] = self.sys_path
            # XXX on Windows the test leaves a directory
            # with xx module in TEMP
        shutil.rmtree(self.tmp_dir, os.name == 'nt' or
                                    sys.platform == 'cygwin')
        super(BuildExtTestCase, self).tearDown() 
Example #21
Source File: test_importhooks.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def testBlocker(self):
        mname = "exceptions"  # an arbitrary harmless builtin module
        test_support.unload(mname)
        sys.meta_path.append(ImportBlocker(mname))
        self.assertRaises(ImportError, __import__, mname) 
Example #22
Source File: test_future.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def test_future1(self):
        test_support.unload('test_future1')
        from test import test_future1
        self.assertEqual(test_future1.result, 6) 
Example #23
Source File: test_future.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def test_future2(self):
        test_support.unload('test_future2')
        from test import test_future2
        self.assertEqual(test_future2.result, 6) 
Example #24
Source File: test_future.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def test_future3(self):
        test_support.unload('test_future3')
        from test import test_future3 
Example #25
Source File: regrtest.py    From BinderFilter with MIT License 5 votes vote down vote up
def runtest_inner(test, verbose, quiet, huntrleaks=False):
    test_support.unload(test)
    if verbose:
        capture_stdout = None
    else:
        capture_stdout = StringIO.StringIO()

    test_time = 0.0
    refleak = False  # True if the test leaked references.
    try:
        save_stdout = sys.stdout
        try:
            if capture_stdout:
                sys.stdout = capture_stdout
            if test.startswith('test.'):
                abstest = test
            else:
                # Always import it from the test package
                abstest = 'test.' + test
            with saved_test_environment(test, verbose, quiet) as environment:
                start_time = time.time()
                the_package = __import__(abstest, globals(), locals(), [])
                the_module = getattr(the_package, test)
                # Old tests run to completion simply as a side-effect of
                # being imported.  For tests based on unittest or doctest,
                # explicitly invoke their test_main() function (if it exists).
                indirect_test = getattr(the_module, "test_main", None)
                if indirect_test is not None:
                    indirect_test()
                if huntrleaks:
                    refleak = dash_R(the_module, test, indirect_test,
                        huntrleaks)
                test_time = time.time() - start_time
        finally:
            sys.stdout = save_stdout
    except test_support.ResourceDenied, msg:
        if not quiet:
            print test, "skipped --", msg
            sys.stdout.flush()
        return RESOURCE_DENIED, test_time 
Example #26
Source File: test_importhooks.py    From BinderFilter with MIT License 5 votes vote down vote up
def testBlocker(self):
        mname = "exceptions"  # an arbitrary harmless builtin module
        test_support.unload(mname)
        sys.meta_path.append(ImportBlocker(mname))
        self.assertRaises(ImportError, __import__, mname) 
Example #27
Source File: test_future.py    From BinderFilter with MIT License 5 votes vote down vote up
def test_future1(self):
        test_support.unload('test_future1')
        from test import test_future1
        self.assertEqual(test_future1.result, 6) 
Example #28
Source File: test_future.py    From BinderFilter with MIT License 5 votes vote down vote up
def test_future2(self):
        test_support.unload('test_future2')
        from test import test_future2
        self.assertEqual(test_future2.result, 6) 
Example #29
Source File: test_future.py    From BinderFilter with MIT License 5 votes vote down vote up
def test_future3(self):
        test_support.unload('test_future3')
        from test import test_future3 
Example #30
Source File: test_build_ext.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def tearDown(self):
        if self.xx_created:
            test_support.unload('xx')
            # XXX on Windows the test leaves a directory
            # with xx module in TEMP
        super(BuildExtTestCase, self).tearDown()