当前位置: 首页>>代码示例>>Python>>正文


Python unittest.main方法代码示例

本文整理汇总了Python中unittest.main方法的典型用法代码示例。如果您正苦于以下问题:Python unittest.main方法的具体用法?Python unittest.main怎么用?Python unittest.main使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unittest的用法示例。


在下文中一共展示了unittest.main方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testCatchBreakInstallsHandler

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import main [as 别名]
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) 
开发者ID:war-and-code,项目名称:jawfish,代码行数:21,代码来源:test_program.py

示例2: test_get_log_for_test

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import main [as 别名]
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') 
开发者ID:linkedin,项目名称:Zopkio,代码行数:20,代码来源:test_test_utils.py

示例3: test_install_plugin_own_project_no_data

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import main [as 别名]
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."]}
        ) 
开发者ID:Pagure,项目名称:pagure,代码行数:23,代码来源:test_pagure_flask_api_plugins_install.py

示例4: test_install_plugin_own_project

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import main [as 别名]
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",
            },
        ) 
开发者ID:Pagure,项目名称:pagure,代码行数:26,代码来源:test_pagure_flask_api_plugins_install.py

示例5: test_install_plugin_someone_else_project_project_less_token

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import main [as 别名]
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",
            },
        ) 
开发者ID:Pagure,项目名称:pagure,代码行数:26,代码来源:test_pagure_flask_api_plugins_install.py

示例6: test_install_plugin_project_specific_token

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import main [as 别名]
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",
            },
        ) 
开发者ID:Pagure,项目名称:pagure,代码行数:26,代码来源:test_pagure_flask_api_plugins_install.py

示例7: test_install_plugin_invalid_project_specific_token

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import main [as 别名]
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"]) 
开发者ID:Pagure,项目名称:pagure,代码行数:23,代码来源:test_pagure_flask_api_plugins_install.py

示例8: test_get_pull_request_ready_branch_no_repo

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import main [as 别名]
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"
        ) 
开发者ID:Pagure,项目名称:pagure,代码行数:19,代码来源:test_pagure_flask_internal.py

示例9: test_get_pull_request_ready_branch_main_repo_no_branch

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import main [as 别名]
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") 
开发者ID:Pagure,项目名称:pagure,代码行数:22,代码来源:test_pagure_flask_internal.py

示例10: test_remove_plugin_own_project_plugin_not_installed

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import main [as 别名]
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"]
        ) 
开发者ID:Pagure,项目名称:pagure,代码行数:22,代码来源:test_pagure_flask_api_plugins_remove.py

示例11: test_remove_plugin_someone_else_project_project_less_token

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import main [as 别名]
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",
            },
        ) 
开发者ID:Pagure,项目名称:pagure,代码行数:23,代码来源:test_pagure_flask_api_plugins_remove.py

示例12: test_remove_plugin_project_specific_token

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import main [as 别名]
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",
            },
        ) 
开发者ID:Pagure,项目名称:pagure,代码行数:23,代码来源:test_pagure_flask_api_plugins_remove.py

示例13: test_create_issue_own_project_no_data

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import main [as 别名]
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."],
            },
        ) 
开发者ID:Pagure,项目名称:pagure,代码行数:25,代码来源:test_pagure_flask_api_issue_create.py

示例14: test_create_issue_own_project_incomplete_data

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import main [as 别名]
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."]}
        ) 
开发者ID:Pagure,项目名称:pagure,代码行数:26,代码来源:test_pagure_flask_api_issue_create.py

示例15: test_create_issue_invalid_project_specific_token

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import main [as 别名]
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"]) 
开发者ID:Pagure,项目名称:pagure,代码行数:26,代码来源:test_pagure_flask_api_issue_create.py


注:本文中的unittest.main方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。