Python unittest.main() Examples

The following are 40 code examples for showing how to use unittest.main(). These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.

You may also want to check out all available functions/classes of the module unittest , or try the search function .

Example 1
Project: jawfish   Author: war-and-code   File: test_program.py    License: MIT License 6 votes vote down vote up
def testCatchBreakInstallsHandler(self):
        module = sys.modules['unittest.main']
        original = module.installHandler
        def restore():
            module.installHandler = original
        self.addCleanup(restore)

        self.installed = False
        def fakeInstallHandler():
            self.installed = True
        module.installHandler = fakeInstallHandler

        program = self.program
        program.catchbreak = True

        program.testRunner = FakeRunner

        program.runTests()
        self.assertTrue(self.installed) 
Example 2
Project: Zopkio   Author: linkedin   File: test_test_utils.py    License: Apache License 2.0 6 votes vote down vote up
def test_get_log_for_test(self):
    """
    Tests if we get the logs for test correctly
    """

    test = testobj.Test("Testing_Logs",None,phase=0,iteration=0)
    test.start_time = time.time()
    time.sleep(2)
    test.end_time = time.time()
    runtime.set_active_tests([test])

    output_path = '/tmp/test_test_utils_logs_output'
    if not os.path.exists(output_path):
      os.mkdir(output_path)
    with open(os.path.join(output_path, 'test.log'), 'w') as f:
      f.write('23:59:59 [main] INFO  Testing_Logs')      
    with open(os.path.join(output_path, 'test.log'), 'w') as f:
      f.write('23:59:59 [main] INFO  TestClientService - Sent 100') 
Example 3
def test_install_plugin_own_project_no_data(self):
        """ Test installing a new plugin on a project for which you're the
        main maintainer.
        """

        # pingou's token with all the ACLs
        headers = {"Authorization": "token aaabbbcccddd"}

        # Install a plugin on /test/ where pingou is the main admin
        output = self.app.post(
            "/api/0/test/settings/Mail/install", headers=headers
        )
        self.assertEqual(output.status_code, 400)
        data = json.loads(output.get_data(as_text=True))
        self.assertEqual(
            pagure.api.APIERROR.EINVALIDREQ.name, data["error_code"]
        )
        self.assertEqual(pagure.api.APIERROR.EINVALIDREQ.value, data["error"])
        self.assertEqual(
            data["errors"], {"mail_to": ["This field is required."]}
        ) 
Example 4
def test_install_plugin_own_project(self):
        """ Test installing a new plugin on a project for which you're the
        main maintainer.
        """

        # pingou's token with all the ACLs
        headers = {"Authorization": "token aaabbbcccddd"}

        # complete data set
        data = {"mail_to": "serg@wh40k.com"}

        # Create an issue on /test/ where pingou is the main admin
        output = self.app.post(
            "/api/0/test/settings/Mail/install", headers=headers, data=data
        )
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.get_data(as_text=True))
        self.assertEqual(
            data,
            {
                "plugin": {"mail_to": "serg@wh40k.com"},
                "message": "Hook 'Mail' activated",
            },
        ) 
Example 5
def test_install_plugin_someone_else_project_project_less_token(self):
        """ Test installing a new plugin on a project with which you have
        nothing to do.
        """

        # pingou's token with all the ACLs
        headers = {"Authorization": "token project-less-foo"}

        # Install a plugin on /test/ where pingou is the main admin
        output = self.app.post(
            "/api/0/test/settings/Prevent creating new branches by git push/"
            "install",
            headers=headers,
        )
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.get_data(as_text=True))
        self.assertEqual(
            data,
            {
                "plugin": {},
                "message": "Hook 'Prevent creating new branches by git push' "
                "activated",
            },
        ) 
Example 6
def test_install_plugin_project_specific_token(self):
        """ Test installing a new plugin on a project with a regular
        project-specific token.
        """

        # pingou's token with all the ACLs
        headers = {"Authorization": "token project-specific-foo"}

        # complete data set
        data = {"mail_to": "serg@wh40k.com"}

        # Create an issue on /test/ where pingou is the main admin
        output = self.app.post(
            "/api/0/test/settings/Mail/install", headers=headers, data=data
        )
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.get_data(as_text=True))
        self.assertEqual(
            data,
            {
                "plugin": {"mail_to": "serg@wh40k.com"},
                "message": "Hook 'Mail' activated",
            },
        ) 
Example 7
def test_install_plugin_invalid_project_specific_token(self):
        """ Test installing a new plugin on a project with a regular
        project-specific token but for another project.
        """

        # pingou's token with all the ACLs
        headers = {"Authorization": "token project-specific-foo"}

        # complete data set
        data = {"mail_to": "serg@wh40k.com"}

        # Create an issue on /test/ where pingou is the main admin
        output = self.app.post(
            "/api/0/test2/settings/Mail/install", headers=headers, data=data
        )
        self.assertEqual(output.status_code, 401)
        data = json.loads(output.get_data(as_text=True))
        self.assertEqual(
            pagure.api.APIERROR.EINVALIDTOK.name, data["error_code"]
        )
        self.assertEqual(pagure.api.APIERROR.EINVALIDTOK.value, data["error"]) 
Example 8
Project: pagure   Author: Pagure   File: test_pagure_flask_internal.py    License: GNU General Public License v2.0 6 votes vote down vote up
def test_get_pull_request_ready_branch_no_repo(self):
        """Test the get_pull_request_ready_branch from the internal API
        on the main repository
        """
        with tests.user_set(self.app.application, tests.FakeUser()):
            csrf_token = self.get_csrf()

        # Query branches on an invalid repo
        data = {"repo": "test", "namespace": "fake", "csrf_token": csrf_token}
        output = self.app.post("/pv/pull-request/ready", data=data)
        self.assertEqual(output.status_code, 404)
        js_data = json.loads(output.get_data(as_text=True))
        self.assertEqual(sorted(js_data.keys()), ["code", "message"])
        self.assertEqual(js_data["code"], "ERROR")
        self.assertEqual(
            js_data["message"], "No repo found with the information provided"
        ) 
Example 9
Project: pagure   Author: Pagure   File: test_pagure_flask_internal.py    License: GNU General Public License v2.0 6 votes vote down vote up
def test_get_pull_request_ready_branch_main_repo_no_branch(self):
        """Test the get_pull_request_ready_branch from the internal API
        on the main repository
        """
        tests.create_projects(self.session)
        tests.create_projects_git(os.path.join(self.path, "repos"), bare=True)

        # Get on with testing
        user = tests.FakeUser()
        user.username = "pingou"
        with tests.user_set(self.app.application, user):
            csrf_token = self.get_csrf()

        # Query branches on the main repo
        data = {"csrf_token": csrf_token, "repo": "test"}
        output = self.app.post("/pv/pull-request/ready", data=data)
        self.assertEqual(output.status_code, 200)
        js_data = json.loads(output.get_data(as_text=True))
        self.assertEqual(sorted(js_data.keys()), ["code", "task"])
        self.assertEqual(js_data["code"], "OK") 
Example 10
def test_remove_plugin_own_project_plugin_not_installed(self):
        """ Test removing a plugin from a project for which you're the
        main maintainer and the plugin is not installed.
        """

        # pingou's token with all the ACLs
        headers = {"Authorization": "token aaabbbcccddd"}

        # Remove a plugin from /test/ where pingou is the main admin
        output = self.app.post(
            "/api/0/test/settings/IRC/remove", headers=headers
        )
        self.assertEqual(output.status_code, 400)
        data = json.loads(output.get_data(as_text=True))
        self.assertEqual(
            pagure.api.APIERROR.EPLUGINNOTINSTALLED.name, data["error_code"]
        )
        self.assertEqual(
            pagure.api.APIERROR.EPLUGINNOTINSTALLED.value, data["error"]
        ) 
Example 11
def test_remove_plugin_someone_else_project_project_less_token(self):
        """ Test removing a plugin from a project with which you have
        nothing to do.
        """

        # pingou's token with all the ACLs
        headers = {"Authorization": "token project-less-foo"}

        # Remove a plugin from /test/ where pingou is the main admin
        output = self.app.post(
            "/api/0/test/settings/Mail/" "remove", headers=headers
        )
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.get_data(as_text=True))
        self.assertEqual(
            data,
            {
                "plugin": {"mail_to": "serg@wh40k.com"},
                "message": "Hook 'Mail' deactivated",
            },
        ) 
Example 12
def test_remove_plugin_project_specific_token(self):
        """ Test removing a plugin from a project with a regular
        project-specific token.
        """

        # pingou's token with all the ACLs
        headers = {"Authorization": "token project-specific-foo"}

        # Remove a plugin from /test/ where pingou is the main admin
        output = self.app.post(
            "/api/0/test/settings/Mail/remove", headers=headers
        )
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.get_data(as_text=True))
        self.assertEqual(
            data,
            {
                "plugin": {"mail_to": "serg@wh40k.com"},
                "message": "Hook 'Mail' deactivated",
            },
        ) 
Example 13
def test_create_issue_own_project_no_data(self):
        """ Test creating a new ticket on a project for which you're the
        main maintainer.
        """

        # pingou's token with all the ACLs
        headers = {"Authorization": "token aaabbbcccddd"}

        # Create an issue on /test/ where pingou is the main admin
        output = self.app.post("/api/0/test/new_issue", headers=headers)
        self.assertEqual(output.status_code, 400)
        data = json.loads(output.get_data(as_text=True))
        self.assertEqual(
            pagure.api.APIERROR.EINVALIDREQ.name, data["error_code"]
        )
        self.assertEqual(pagure.api.APIERROR.EINVALIDREQ.value, data["error"])
        self.assertEqual(
            data["errors"],
            {
                "issue_content": ["This field is required."],
                "title": ["This field is required."],
            },
        ) 
Example 14
def test_create_issue_own_project_incomplete_data(self):
        """ Test creating a new ticket on a project for which you're the
        main maintainer.
        """

        # pingou's token with all the ACLs
        headers = {"Authorization": "token aaabbbcccddd"}

        # complete data set
        data = {"title": "test issue"}

        # Create an issue on /test/ where pingou is the main admin
        output = self.app.post(
            "/api/0/test/new_issue", headers=headers, data=data
        )
        self.assertEqual(output.status_code, 400)
        data = json.loads(output.get_data(as_text=True))
        self.assertEqual(
            pagure.api.APIERROR.EINVALIDREQ.name, data["error_code"]
        )
        self.assertEqual(pagure.api.APIERROR.EINVALIDREQ.value, data["error"])
        self.assertEqual(
            data["errors"], {"issue_content": ["This field is required."]}
        ) 
Example 15
def test_create_issue_invalid_project_specific_token(self):
        """ Test creating a new ticket on a project with a regular
        project-specific token but for another project.
        """

        # pingou's token with all the ACLs
        headers = {"Authorization": "token project-specific-foo"}

        # complete data set
        data = {
            "title": "test issue",
            "issue_content": "This issue needs attention",
        }

        # Create an issue on /test/ where pingou is the main admin
        output = self.app.post(
            "/api/0/test2/new_issue", headers=headers, data=data
        )
        self.assertEqual(output.status_code, 401)
        data = json.loads(output.get_data(as_text=True))
        self.assertEqual(
            pagure.api.APIERROR.EINVALIDTOK.name, data["error_code"]
        )
        self.assertEqual(pagure.api.APIERROR.EINVALIDTOK.value, data["error"]) 
Example 16
Project: hammer   Author: ucb-bar   File: cli_driver_test.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def run_syn_to_par_with_output(self, config_path: str, syn_rundir: str,
                                   par_rundir: str,
                                   syn_out_path: str,
                                   syn_to_par_out_path: str) -> None:
        # Check that running the CLIDriver executes successfully (code 0).
        with self.assertRaises(SystemExit) as cm:  # type: ignore
            CLIDriver().main(args=[
                "syn",  # action
                "-p", config_path,
                "--output", syn_out_path,
                "--syn_rundir", syn_rundir,
                "--par_rundir", par_rundir
            ])
        self.assertEqual(cm.exception.code, 0)
        # Now run syn-to-par with the main config as well as the outputs.
        with self.assertRaises(SystemExit) as cm:  # type: ignore
            CLIDriver().main(args=[
                "syn-to-par",  # action
                "-p", config_path,
                "-p", syn_out_path,
                "--output", syn_to_par_out_path,
                "--syn_rundir", syn_rundir,
                "--par_rundir", par_rundir
            ])
        self.assertEqual(cm.exception.code, 0) 
Example 17
Project: fishroom   Author: tuna   File: telegram.py    License: GNU General Public License v3.0 5 votes vote down vote up
def main():
    if "telegram" not in config:
        return

    from .runner import run_threads
    tg, im2fish_bus, fish2im_bus = init()
    run_threads([
        (Telegram2FishroomThread, (tg, im2fish_bus, ), ),
        (Fishroom2TelegramThread, (tg, fish2im_bus, ), ),
    ]) 
Example 18
Project: fishroom   Author: tuna   File: telegram.py    License: GNU General Public License v3.0 5 votes vote down vote up
def test():
    unittest.main()

    from .photostore import VimCN

    tele = Telegram(config['telegram']['token'],
                    nick_store=MemNickStore(), photo_store=VimCN())
    # tele.send_msg('user#67655173', 'hello')
    tele.send_photo('-34678255', open('test.png', 'rb').read())
    tele.send_msg('-34678255', "Back!")
    for msg in tele.message_stream():
        print(msg.dumps())
        tele.send_msg(msg.receiver, msg.content)
    return 
Example 19
Project: pyhanlp   Author: hankcs   File: test_hanlp.py    License: Apache License 2.0 5 votes vote down vote up
def test():
    unittest.main() 
Example 20
Project: pyhanlp   Author: hankcs   File: test_multithread.py    License: Apache License 2.0 5 votes vote down vote up
def test():
    unittest.main() 
Example 21
Project: EXOSIMS   Author: dsavransky   File: test_OpticalSystem.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_init_iwa_owa(self):
        r"""Test of initialization and __init__ -- IWA, OWA.

        Method: We instantiate OpticalSystem objects and verify 
        various IWA/OWA relationships.
        """
        for specs in [specs_default, specs_simple, specs_multi]:
            # the input dict is modified in-place -- so copy it
            our_specs = deepcopy(specs)
            # set root object IWA and OWA in conflict
            our_specs['IWA'] = 10
            our_specs['OWA'] = 1
            with self.assertRaises(AssertionError):
                optsys = self.fixture(**deepcopy(our_specs))
        for specs in [specs_default, specs_simple, specs_multi]:
            # various settings of sub-object IWA and OWA
            for IWA, OWA in zip([1, 1, 10, 10, 20, 20], [5, 15, 5, 15, 5, 15]):
                # the input dict is modified in-place -- so copy it
                our_specs = deepcopy(specs)
                # set sub-object IWA and OWA 
                for syst in our_specs['starlightSuppressionSystems']:
                    syst['IWA'] = IWA
                    syst['OWA'] = OWA
                if IWA < OWA:
                    # will succeed in this case
                    optsys = self.fixture(**deepcopy(our_specs))
                    # they must propagate up to main object
                    self.assertTrue(optsys.OWA.value == OWA)
                    self.assertTrue(optsys.IWA.value == IWA)
                else:
                    # they propagate up, and cause a failure
                    with self.assertRaises(AssertionError):
                        optsys = self.fixture(**deepcopy(our_specs)) 
Example 22
Project: EXOSIMS   Author: dsavransky   File: test_TargetList.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_main_sequence_filter(self):
        n0 = self.targetlist.nStars
        self.targetlist.main_sequence_filter()
        #print self.targetlist.nStars
        #Check that no stars fall outside main sequence strip
        self.assertEqual( np.any((self.targetlist.BV < 0.74) & (self.targetlist.MV > 6*self.targetlist.BV+1.8)) , False)
        self.assertEqual( np.any((self.targetlist.BV >= 0.74) & (self.targetlist.BV < 1.37) & (self.targetlist.MV > 4.3*self.targetlist.BV+3.05)) , False)
        self.assertEqual( np.any((self.targetlist.BV >= 1.37) & (self.targetlist.MV > 18*self.targetlist.BV-15.7)) , False)
        self.assertEqual( np.any((self.targetlist.BV < 0.87) & (self.targetlist.MV < -8*(self.targetlist.BV-1.35)**2+7.01)) , False)
        self.assertEqual( np.any((self.targetlist.BV >= 0.87) & (self.targetlist.BV < 1.45) & (self.targetlist.MV > 5*self.targetlist.BV+0.81)) , False)
        self.assertEqual( np.any((self.targetlist.BV >= 1.45) & (self.targetlist.MV < 18*self.targetlist.BV-18.04)) , False)
        #check that filtered target list does not have repeating elements
        import collections
        compare = lambda x, y: collections.Counter(x) == collections.Counter(y)
        self.assertEqual( compare(list(set(self.targetlist.Name)), list(self.targetlist.Name)) , True) 
Example 23
Project: myhdl   Author: myhdl   File: test_all.py    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
def main():
    unittest.main(defaultTest='suite',
                  testRunner=unittest.TextTestRunner(verbosity=2)) 
Example 24
Project: myhdl   Author: myhdl   File: test_all.py    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
def main():
    unittest.main(defaultTest='suite',
                  testRunner=unittest.TextTestRunner(verbosity=2)) 
Example 25
Project: myhdl   Author: myhdl   File: test_all.py    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
def main():
    unittest.main(defaultTest='suite',
                  testRunner=unittest.TextTestRunner(verbosity=2)) 
Example 26
Project: myhdl   Author: myhdl   File: test_all.py    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
def main():
    unittest.main(defaultTest='suite',
                  testRunner=unittest.TextTestRunner(verbosity=2)) 
Example 27
Project: leveldb-py   Author: jtolio   File: test_leveldb.py    License: MIT License 5 votes vote down vote up
def main():
    parser = argparse.ArgumentParser("run tests")
    parser.add_argument("--runs", type=int, default=1)
    args = parser.parse_args()
    for _ in xrange(args.runs):
        unittest.main(argv=sys.argv[:1], exit=False) 
Example 28
Project: jawfish   Author: war-and-code   File: test_program.py    License: MIT License 5 votes vote down vote up
def test_NonExit(self):
        program = unittest.main(exit=False,
                                argv=["foobar"],
                                testRunner=unittest.TextTestRunner(stream=io.StringIO()),
                                testLoader=self.FooBarLoader())
        self.assertTrue(hasattr(program, 'result')) 
Example 29
Project: jawfish   Author: war-and-code   File: test_program.py    License: MIT License 5 votes vote down vote up
def test_Exit(self):
        self.assertRaises(
            SystemExit,
            unittest.main,
            argv=["foobar"],
            testRunner=unittest.TextTestRunner(stream=io.StringIO()),
            exit=True,
            testLoader=self.FooBarLoader()) 
Example 30
Project: jawfish   Author: war-and-code   File: test_program.py    License: MIT License 5 votes vote down vote up
def test_ExitAsDefault(self):
        self.assertRaises(
            SystemExit,
            unittest.main,
            argv=["foobar"],
            testRunner=unittest.TextTestRunner(stream=io.StringIO()),
            testLoader=self.FooBarLoader()) 
Example 31
Project: python-esppy   Author: sassoftware   File: utils.py    License: Apache License 2.0 5 votes vote down vote up
def runtests(xmlrunner=False):
   ''' Run unit tests '''
   import sys

   if '--profile' in sys.argv:
       import profile
       import pstats

       sys.argv = [x for x in sys.argv if x != '--profile']

       if xmlrunner:
           import xmlrunner as xr
           profile.run("unittest.main(testRunner=xr.XMLTestRunner(output='test-reports', verbosity=2))", '_stats.txt')
       else:
           profile.run('unittest.main()', '_stats.txt')

       stats = pstats.Stats('_stats.txt')
       #stats.strip_dirs()
       stats.sort_stats('cumulative', 'calls')
       stats.print_stats(25)
       stats.sort_stats('time', 'calls')
       stats.print_stats(25)

   elif xmlrunner:
       import xmlrunner as xr
       unittest.main(testRunner=xr.XMLTestRunner(output='test-reports', verbosity=2)) 

   else:
       unittest.main() 
Example 32
Project: OpenTrader   Author: OpenTrading   File: OTCmd2.py    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
def iMain(lCmdLine):

    if '--test' in lCmdLine:
        # legacy - unused
        sys.argv = [sys.argv[0]]  # the --test argument upsets unittest.main()
        unittest.main()
        return 0

    oApp = None
    try:
        oArgParser = oParseOptions()
        oOptions = oArgParser.parse_args(lCmdLine)

        sConfigFile = oOptions.sConfigFile
        oConfig = oParseConfig(sConfigFile)
        oConfig = oMergeConfig(oConfig, oOptions)

        oApp = CmdLineApp(oConfig, oOptions.lArgs)

        if oOptions.lArgs:
            oApp.onecmd_plus_hooks(' '.join(oOptions.lArgs) +'\n')
        else:
            oApp._cmdloop()
    except KeyboardInterrupt:
        pass
    except Exception as e:
        print traceback.format_exc(10)
    # always reached
    if oApp:
        oApp.vAtexit()

        l = threading.enumerate()
        if len(l) > 1:
            print "WARN: Threads still running: %r" % (l,) 
Example 33
Project: OpenTrader   Author: OpenTrading   File: cmd2plus.py    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
def runTranscriptTests(self, callargs):
        class TestMyAppCase(Cmd2TestCase):
            CmdApp = self.__class__
        self.__class__.testfiles = callargs
        sys.argv = [sys.argv[0]] # the --test argument upsets unittest.main()
        testcase = TestMyAppCase()
        runner = unittest.TextTestRunner()
        result = runner.run(testcase)
        result.printErrors() 
Example 34
Project: Zopkio   Author: linkedin   File: test_zopkio.py    License: Apache License 2.0 5 votes vote down vote up
def _run_zopkio(self, args):
    import sys, os.path
    pwd = os.path.abspath('.')
    try:
      os.chdir(os.path.join(os.path.dirname(__file__),".."))
      sys.args = args
      print("Running 'zopkio %s %s'"%(args.testfile, args.nopassword))
      from zopkio import __main__ as main
      succeeded, failed = main.call_main(args)
    except:
      os.chdir( pwd )
      raise
    else:
      return succeeded, failed 
Example 35
Project: hsds   Author: HDFGroup   File: hdf5dtypeTest.py    License: Apache License 2.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        super(Hdf5dtypeTest, self).__init__(*args, **kwargs)
        # main
        self.logger = logging.getLogger()
        self.logger.setLevel(logging.INFO) 
Example 36
Project: misp42splunk   Author: remg427   File: test_main.py    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
def tearDown(self):
        # Clean up logging configuration down by main.
        del logging.root.handlers[:]
        if self.temp_dir:
            shutil.rmtree(self.temp_dir) 
Example 37
Project: misp42splunk   Author: remg427   File: test_main.py    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
def run_2to3_capture(self, args, in_capture, out_capture, err_capture):
        save_stdin = sys.stdin
        save_stdout = sys.stdout
        save_stderr = sys.stderr
        sys.stdin = in_capture
        sys.stdout = out_capture
        sys.stderr = err_capture
        try:
            return main.main("lib2to3.fixes", args)
        finally:
            sys.stdin = save_stdin
            sys.stdout = save_stdout
            sys.stderr = save_stderr 
Example 38
Project: misp42splunk   Author: remg427   File: test_main.py    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
def tearDown(self):
        # Clean up logging configuration down by main.
        del logging.root.handlers[:]
        if self.temp_dir:
            shutil.rmtree(self.temp_dir) 
Example 39
Project: misp42splunk   Author: remg427   File: test_main.py    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
def run_2to3_capture(self, args, in_capture, out_capture, err_capture):
        save_stdin = sys.stdin
        save_stdout = sys.stdout
        save_stderr = sys.stderr
        sys.stdin = in_capture
        sys.stdout = out_capture
        sys.stderr = err_capture
        try:
            return main.main("lib2to3.fixes", args)
        finally:
            sys.stdin = save_stdin
            sys.stdout = save_stdout
            sys.stderr = save_stderr 
Example 40
Project: recipes-py   Author: luci   File: test_env.py    License: Apache License 2.0 5 votes vote down vote up
def main():
  if '-v' in sys.argv or '--verbose' in sys.argv:
    logging.basicConfig(
      level=logging.DEBUG,
      handler=CapturableHandler())
  sys.exit(unittest.main())