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


Python ErrorBundle.pop_state方法代码示例

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


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

示例1: test_pushable_resources

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import pop_state [as 别名]
def test_pushable_resources():
    """
    Test that normal resources are preserved but pushable ones are pushed.
    """

    e = ErrorBundle()
    e.save_resource("nopush", True)
    e.save_resource("push", True, pushable=True)

    assert e.get_resource("nopush")
    assert e.get_resource("push")

    e.push_state()

    assert e.get_resource("nopush")
    assert not e.get_resource("push")

    e.save_resource("pushed", True, pushable=True)
    assert e.get_resource("pushed")

    e.pop_state()

    assert e.get_resource("nopush")
    assert e.get_resource("push")
    assert not e.get_resource("pushed")
开发者ID:kmaglione,项目名称:amo-validator,代码行数:27,代码来源:test_errorbundler.py

示例2: test_states

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import pop_state [as 别名]
def test_states():
    """Test that detected type is preserved, even in subpackages."""

    # Use the StringIO as an output buffer.
    bundle = ErrorBundle()

    # Populate the bundle with some test data.
    bundle.detected_type = 4
    bundle.error((), "error")
    bundle.warning((), "warning")
    bundle.notice((), "notice")
    bundle.save_resource("test", True)

    # Push a state
    bundle.push_state("test.xpi")

    bundle.detected_type = 2
    bundle.error((), "nested error")
    bundle.warning((), "nested warning")
    bundle.notice((), "nested notice")

    # Push another state
    bundle.push_state("test2.xpi")

    bundle.detected_type = 3
    bundle.error((), "super nested error")
    bundle.warning((), "super nested warning")
    bundle.notice((), "super nested notice")

    # Test that nested compatibility messages retain various # properties.
    bundle.notice("comp", "Compat Test notice", compatibility_type="error", editors_only=True, signing_severity="high")

    bundle.pop_state()

    bundle.pop_state()

    # Load the JSON output as an object.
    output = json.loads(bundle.render_json())

    # Run some basic tests
    assert output["detected_type"] == "langpack"
    assert len(output["messages"]) == 10

    messages = [
        "error",
        "warning",
        "notice",
        "nested error",
        "nested warning",
        "nested notice",
        "super nested error",
        "super nested warning",
        "super nested notice",
        "Compat Test notice",
    ]

    for message in output["messages"]:
        assert message["message"] in messages
        messages.remove(message["message"])

        assert message["message"].endswith(message["type"])

        if message["id"] == "comp":
            assert message["compatibility_type"] == "error"
            assert message["editors_only"] == True
            assert message["signing_severity"] == "high"

    assert not messages

    assert bundle.get_resource("test")
开发者ID:kmaglione,项目名称:amo-validator,代码行数:72,代码来源:test_errorbundler.py

示例3: test_file_structure

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import pop_state [as 别名]
def test_file_structure():
    """
    Test the means by which file names and line numbers are stored in errors,
    warnings, and messages.
    """

    # Use the StringIO as an output buffer.
    bundle = ErrorBundle(determined=True)

    # Populate the bundle with some test data.
    bundle.error((), "error", description="", filename="file1", column=123)
    bundle.error((), "error", description="", filename="file2")
    bundle.error((), "error")

    # Push a state
    bundle.push_state("foo")

    bundle.warning((), "warning", description="", filename="file4", column=123)
    bundle.warning((), "warning", description="", filename="file5")
    bundle.warning((), "warning")

    bundle.pop_state()

    # Load the JSON output as an object.
    output = json.loads(bundle.render_json())

    # Do the same for friendly output
    output2 = bundle.print_summary(verbose=False)

    # Do the same for verbose friendly output
    output3 = bundle.print_summary(verbose=True)

    # Run some basic tests
    assert len(output["messages"]) == 6
    assert len(output2) < len(output3)

    print output
    print "*" * 50
    print output2
    print "*" * 50
    print output3
    print "*" * 50

    messages = ["file1", "file2", "", ["foo", "file4"], ["foo", "file5"], ["foo", ""]]

    for message in output["messages"]:
        print message

        assert message["file"] in messages
        messages.remove(message["file"])

        if isinstance(message["file"], list):
            pattern = message["file"][:]
            pattern.pop()
            pattern.append("")
            file_merge = " > ".join(pattern)
            print file_merge
            assert output3.count(file_merge)
        else:
            assert output3.count(message["file"])

    assert not messages
开发者ID:kmaglione,项目名称:amo-validator,代码行数:64,代码来源:test_errorbundler.py

示例4: test_states

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import pop_state [as 别名]
def test_states():
    """Test that detected type is preserved, even in subpackages."""

    # Use the StringIO as an output buffer.
    bundle = ErrorBundle()

    # Populate the bundle with some test data.
    bundle.detected_type = 4
    bundle.error((), 'error')
    bundle.warning((), 'warning')
    bundle.notice((), 'notice')
    bundle.save_resource('test', True)

    # Push a state
    bundle.push_state('test.xpi')

    bundle.detected_type = 2
    bundle.error((), 'nested error')
    bundle.warning((), 'nested warning')
    bundle.notice((), 'nested notice')

    # Push another state
    bundle.push_state('test2.xpi')

    bundle.detected_type = 3
    bundle.error((), 'super nested error')
    bundle.warning((), 'super nested warning')
    bundle.notice((), 'super nested notice')

    # Test that nested compatibility messages retain various # properties.
    bundle.notice('comp', 'Compat Test notice',
                  compatibility_type='error',
                  editors_only=True,
                  signing_severity='high')

    bundle.pop_state()

    bundle.pop_state()

    # Load the JSON output as an object.
    output = json.loads(bundle.render_json())

    # Run some basic tests
    assert output['detected_type'] == 'langpack'
    assert len(output['messages']) == 10

    messages = ['error',
                'warning',
                'notice',
                'nested error',
                'nested warning',
                'nested notice',
                'super nested error',
                'super nested warning',
                'super nested notice',
                'Compat Test notice']

    for message in output['messages']:
        assert message['message'] in messages
        messages.remove(message['message'])

        assert message['message'].endswith(message['type'])

        if message['id'] == 'comp':
            assert message['compatibility_type'] == 'error'
            assert message['editors_only'] is True
            assert message['signing_severity'] == 'high'

    assert not messages

    assert bundle.get_resource('test')
开发者ID:AutomatedTester,项目名称:amo-validator,代码行数:73,代码来源:test_errorbundler.py

示例5: test_file_structure

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import pop_state [as 别名]
def test_file_structure():
    """
    Test the means by which file names and line numbers are stored in errors,
    warnings, and messages.
    """

    # Use the StringIO as an output buffer.
    bundle = ErrorBundle(True)  # No color since no output

    # Populate the bundle with some test data.
    bundle.error((), 'error', description='',
                 filename='file1', column=123)
    bundle.error((), 'error', description='',
                 filename='file2')
    bundle.error((), 'error')

    # Push a state
    bundle.push_state('foo')

    bundle.warning((), 'warning', description='',
                   filename='file4', column=123)
    bundle.warning((), 'warning', description='',
                   filename='file5')
    bundle.warning((), 'warning')

    bundle.pop_state()

    # Load the JSON output as an object.
    output = json.loads(bundle.render_json())

    # Do the same for friendly output
    output2 = bundle.print_summary(verbose=False)

    # Do the same for verbose friendly output
    output3 = bundle.print_summary(verbose=True)

    # Run some basic tests
    assert len(output['messages']) == 6
    assert len(output2) < len(output3)

    print output
    print '*' * 50
    print output2
    print '*' * 50
    print output3
    print '*' * 50

    messages = ['file1', 'file2', '',
                ['foo', 'file4'], ['foo', 'file5'], ['foo', '']]

    for message in output['messages']:
        print message

        assert message['file'] in messages
        messages.remove(message['file'])

        if isinstance(message['file'], list):
            pattern = message['file'][:]
            pattern.pop()
            pattern.append('')
            file_merge = ' > '.join(pattern)
            print file_merge
            assert output3.count(file_merge)
        else:
            assert output3.count(message['file'])

    assert not messages
开发者ID:AutomatedTester,项目名称:amo-validator,代码行数:69,代码来源:test_errorbundler.py

示例6: test_states

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import pop_state [as 别名]
def test_states():
    """Tests that detected type is preserved, even in subpackages."""
    
    # Use the StringIO as an output buffer.
    bundle = ErrorBundle()
    
    # Populate the bundle with some test data.
    bundle.set_type(4)
    bundle.error((), "error")
    bundle.warning((), "warning")
    bundle.notice((), "notice")
    bundle.save_resource("test", True)
    
    # Push a state
    bundle.push_state("test.xpi")
    
    bundle.set_type(2)
    bundle.error((), "nested error")
    bundle.warning((), "nested warning")
    bundle.notice((), "nested notice")
    
    # Push another state
    bundle.push_state("test2.xpi")
    
    bundle.set_type(3)
    bundle.error((), "super nested error")
    bundle.warning((), "super nested warning")
    bundle.notice((), "super nested notice")
    
    bundle.pop_state()
    
    bundle.pop_state()
    
    # Load the JSON output as an object.
    output = json.loads(bundle.render_json())
    
    # Run some basic tests
    assert output["detected_type"] == "langpack"
    assert len(output["messages"]) == 9
    
    print output
    
    messages = ["error",
                "warning",
                "notice",
                "nested error",
                "nested warning",
                "nested notice",
                "super nested error",
                "super nested warning",
                "super nested notice"]
    
    for message in output["messages"]:
        print message
        
        assert message["message"] in messages
        messages.remove(message["message"])
        
        assert message["message"].endswith(message["type"])
    
    assert not messages
    
    assert bundle.get_resource("test")
开发者ID:nmaier,项目名称:amo-validator,代码行数:65,代码来源:test_errorbundler.py


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