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


Python pytest.fail方法代码示例

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


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

示例1: test_dash_in_project_slug

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import fail [as 别名]
def test_dash_in_project_slug(cookies):
    ctx = {'project_slug': "my-package"}
    project = cookies.bake(extra_context=ctx)

    assert project.exit_code == 0

    with open(os.path.join(str(project.project), 'setup.py')) as f:
        setup = f.read()
    print(setup)

    cwd = os.getcwd()
    os.chdir(str(project.project))

    try:
        sh.python(['setup.py', 'install'])
        sh.python(['setup.py', 'build_sphinx'])
    except sh.ErrorReturnCode as e:
        pytest.fail(e)
    finally:
        os.chdir(cwd) 
开发者ID:NLeSC,项目名称:python-template,代码行数:22,代码来源:test_values.py

示例2: test_vectors

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import fail [as 别名]
def test_vectors():
    with open("vectors.json", "r") as f:
        vectors = json.load(f)
    for description, mnemonics, secret in vectors:
        if secret:
            assert bytes.fromhex(secret) == shamir.combine_mnemonics(
                mnemonics, b"TREZOR"
            ), 'Incorrect secret for test vector "{}".'.format(description)
        else:
            with pytest.raises(MnemonicError):
                shamir.combine_mnemonics(mnemonics)
                pytest.fail(
                    'Failed to raise exception for test vector "{}".'.format(
                        description
                    )
                ) 
开发者ID:trezor,项目名称:python-shamir-mnemonic,代码行数:18,代码来源:test_shamir.py

示例3: test_double_quotes_in_name_and_description

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import fail [as 别名]
def test_double_quotes_in_name_and_description(cookies):
    ctx = {'project_short_description': '"double quotes"',
           'full_name': '"name"name'}
    project = cookies.bake(extra_context=ctx)

    assert project.exit_code == 0

    with open(os.path.join(str(project.project), 'setup.py')) as f:
        setup = f.read()
    print(setup)

    cwd = os.getcwd()
    os.chdir(str(project.project))

    try:
        sh.python(['setup.py', 'install'])
    except sh.ErrorReturnCode as e:
        pytest.fail(e)
    finally:
        os.chdir(cwd) 
开发者ID:NLeSC,项目名称:python-template,代码行数:22,代码来源:test_values.py

示例4: test_single_quotes_in_name_and_description

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import fail [as 别名]
def test_single_quotes_in_name_and_description(cookies):
    ctx = {'project_short_description': "'single quotes'",
           'full_name': "Mr. O'Keeffe"}
    project = cookies.bake(extra_context=ctx)

    assert project.exit_code == 0

    with open(os.path.join(str(project.project), 'setup.py')) as f:
        setup = f.read()
    print(setup)

    cwd = os.getcwd()
    os.chdir(str(project.project))

    try:
        sh.python(['setup.py', 'install'])
    except sh.ErrorReturnCode as e:
        pytest.fail(e)
    finally:
        os.chdir(cwd) 
开发者ID:NLeSC,项目名称:python-template,代码行数:22,代码来源:test_values.py

示例5: test_space_in_project_slug

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import fail [as 别名]
def test_space_in_project_slug(cookies):
    ctx = {'project_slug': "my package"}
    project = cookies.bake(extra_context=ctx)

    assert project.exit_code == 0

    with open(os.path.join(str(project.project), 'setup.py')) as f:
        setup = f.read()
    print(setup)

    cwd = os.getcwd()
    os.chdir(str(project.project))

    try:
        sh.python(['setup.py', 'install'])
        sh.python(['setup.py', 'build_sphinx'])
    except sh.ErrorReturnCode as e:
        pytest.fail(e)
    finally:
        os.chdir(cwd) 
开发者ID:NLeSC,项目名称:python-template,代码行数:22,代码来源:test_values.py

示例6: test_install

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import fail [as 别名]
def test_install(cookies):
    project = cookies.bake()

    assert project.exit_code == 0
    assert project.exception is None

    cwd = os.getcwd()
    os.chdir(str(project.project))

    try:
        sh.python(['setup.py', 'install'])
    except sh.ErrorReturnCode as e:
        pytest.fail(e)
    finally:
        os.chdir(cwd) 
开发者ID:NLeSC,项目名称:python-template,代码行数:17,代码来源:test_project.py

示例7: test_building_documentation_apidocs

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import fail [as 别名]
def test_building_documentation_apidocs(cookies):
    project = cookies.bake(extra_context={'apidoc': 'yes'})

    assert project.exit_code == 0
    assert project.exception is None

    cwd = os.getcwd()
    os.chdir(str(project.project))

    try:
        sh.python(['setup.py', 'build_sphinx'])
    except sh.ErrorReturnCode as e:
        pytest.fail(e)
    finally:
        os.chdir(cwd)

    apidocs = project.project.join('docs', '_build', 'html', 'apidocs')

    assert apidocs.join('my_python_project.html').isfile()
    assert apidocs.join('my_python_project.my_python_project.html').isfile() 
开发者ID:NLeSC,项目名称:python-template,代码行数:22,代码来源:test_project.py

示例8: test_orphaned_components

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import fail [as 别名]
def test_orphaned_components(simple_linear_model):
    model = simple_linear_model
    model.nodes["Input"].max_flow = ConstantParameter(model, 10.0)

    result = model.find_orphaned_parameters()
    assert(not result)
    # assert that warning not raised by check
    with pytest.warns(None) as record:
        model.check()
    for w in record:
        if isinstance(w, OrphanedParameterWarning):
            pytest.fail("OrphanedParameterWarning raised unexpectedly!")

    # add some orphans
    orphan1 = ConstantParameter(model, 5.0)
    orphan2 = ConstantParameter(model, 10.0)
    orphans = {orphan1, orphan2}
    result = model.find_orphaned_parameters()
    assert(orphans == result)

    with pytest.warns(OrphanedParameterWarning):
        model.check() 
开发者ID:pywr,项目名称:pywr,代码行数:24,代码来源:test_parameters.py

示例9: test_log_returns

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import fail [as 别名]
def test_log_returns():

    s1 = Stream([200.23, 198.35, 244.36, 266.30, 250.40], "price")
    assert s1.name == "price"

    lp = s1.log()
    lr = lp - lp.lag()

    feed = DataFeed([lr])
    feed.compile()

    while feed.has_next():
        print(feed.next())

    lr = s1.log().diff().rename("log_return")

    feed = DataFeed([lr])
    feed.compile()

    while feed.has_next():
        print(feed.next())

    # pytest.fail("Failed.") 
开发者ID:tensortrade-org,项目名称:tensortrade,代码行数:25,代码来源:test_node_builder_patterns.py

示例10: test_multisig_to_redeemscript_too_long

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import fail [as 别名]
def test_multisig_to_redeemscript_too_long(self):
        # Maximum is 15 compressed keys in a multisig:
        try:
            public_keys = [b'\x00' * 33] * 15
            multisig_to_redeemscript(public_keys, 1)
        except ValueError:  # pragma: no cover
            pytest.fail("multisig_to_redeemscript did not accept 15 compressed public keys.")

        public_keys = [b'\x00' * 33] * 16
        with pytest.raises(ValueError):
            multisig_to_redeemscript(public_keys, 1)

        # Maximum is 7 uncompressed keys in a multisig
        try:
            public_keys = [b'\x00' * 65] * 7
            multisig_to_redeemscript(public_keys, 1)
        except ValueError:  # pragma: no cover
            pytest.fail("multisig_to_redeemscript did not accept 7 uncompressed public keys.")

        public_keys = [b'\x00' * 65] * 8
        with pytest.raises(ValueError):
            multisig_to_redeemscript(public_keys, 1) 
开发者ID:ofek,项目名称:bit,代码行数:24,代码来源:test_format.py

示例11: _runTest

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import fail [as 别名]
def _runTest(self):
        self._linter.check([self._test_file.module])

        expected_messages, expected_text = self._get_expected()
        received_messages, received_text = self._get_received()

        if expected_messages != received_messages:
            msg = ['Wrong results for file "%s":' % (self._test_file.base)]
            missing, unexpected = multiset_difference(expected_messages,
                                                      received_messages)
            if missing:
                msg.append('\nExpected in testdata:')
                msg.extend(' %3d: %s' % msg for msg in sorted(missing))
            if unexpected:
                msg.append('\nUnexpected in testdata:')
                msg.extend(' %3d: %s' % msg for msg in sorted(unexpected))
            pytest.fail('\n'.join(msg))
        self._check_output_text(expected_messages, expected_text, received_text) 
开发者ID:Shopify,项目名称:shopify_python,代码行数:20,代码来源:test_functional.py

示例12: test_default

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import fail [as 别名]
def test_default(ruleset, test, destaddr):
    """
    Default tester with no logger obj. Useful for HTML contains and Status code
    Not useful for testing loggers
    """
    runner = testrunner.TestRunner()
    try:
        last_ua = http.HttpUA()
        for stage in test.stages:
            if destaddr is not None:
                stage.input.dest_addr = destaddr
            if stage.input.save_cookie:
                runner.run_stage(stage, http_ua=last_ua)
            else:
                runner.run_stage(stage, logger_obj=None, http_ua=None)
    except errors.TestError as e:
        e.args[1]['meta'] = ruleset.meta
        pytest.fail('Failure! Message -> {0}, Context -> {1}'.format(
                    e.args[0], e.args[1])) 
开发者ID:CRS-support,项目名称:ftw,代码行数:21,代码来源:test_cookie.py

示例13: test_default

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import fail [as 别名]
def test_default(ruleset, test, destaddr, port, protocol):
    """
    Default tester with no logger obj. Useful for HTML contains and Status code
    Not useful for testing loggers
    """
    runner = testrunner.TestRunner()
    try:
        for stage in test.stages:
            if destaddr is not None:
                stage.input.dest_addr = destaddr
            if port is not None:
                stage.input.port = port
            if protocol is not None:
                stage.input.protocol = protocol
            runner.run_stage(stage, None)
    except errors.TestError as e:
        e.args[1]['meta'] = ruleset.meta
        pytest.fail('Failure! Message -> {0}, Context -> {1}'.format(
                    e.args[0], e.args[1])) 
开发者ID:CRS-support,项目名称:ftw,代码行数:21,代码来源:test_default.py

示例14: emit

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import fail [as 别名]
def emit(self, record):
        logger = logging.getLogger(record.name)
        root_logger = logging.getLogger()

        if logger.name == 'messagemock':
            return

        if (logger.level == record.levelno or
                root_logger.level == record.levelno):
            # caplog.at_level(...) was used with the level of this message,
            # i.e.  it was expected.
            return
        if record.levelno < self._min_level:
            return
        pytest.fail("Got logging message on logger {} with level {}: "
                    "{}!".format(record.name, record.levelname,
                                 record.getMessage())) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:19,代码来源:logfail.py

示例15: test_results_with_error

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import fail [as 别名]
def test_results_with_error(conn_cnx):
    """Gets results with error."""
    with conn_cnx() as cnx:
        cur = cnx.cursor()
        sfqid = None
        try:
            cur.execute("select blah")
            pytest.fail("Should fail here!")
        except ProgrammingError as e:
            sfqid = e.sfqid

        got_sfqid = None
        try:
            cur.query_result(sfqid)
            pytest.fail("Should fail here again!")
        except ProgrammingError as e:
            got_sfqid = e.sfqid

        assert got_sfqid is not None
        assert got_sfqid == sfqid 
开发者ID:snowflakedb,项目名称:snowflake-connector-python,代码行数:22,代码来源:test_results.py


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