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


Python ErrorBundle.push_state方法代码示例

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


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

示例1: test_pushable_resources

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import push_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_subpackage

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import push_state [as 别名]
def test_subpackage():
    "Test a package with localization that should pass validation."

    err = ErrorBundle()
    err.set_type(PACKAGE_DICTIONARY)
    assert l10n.test_xpi(err, None) is None
    err.set_type(PACKAGE_EXTENSION)
    err.push_state()
    assert l10n.test_xpi(err, None) is None
开发者ID:andymckay,项目名称:amo-validator,代码行数:11,代码来源:test_l10n.py

示例3: test_subpackage

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import push_state [as 别名]
def test_subpackage():
    'Test a package with localization that should pass validation.'

    err = ErrorBundle()
    err.detected_type = PACKAGE_DICTIONARY
    assert l10n.test_xpi(err, None) is None
    err.detected_type = PACKAGE_EXTENSION
    err.push_state()
    assert l10n.test_xpi(err, None) is None
开发者ID:kmaglione,项目名称:amo-validator,代码行数:11,代码来源:test_l10n.py

示例4: test_unsigned_inner_xpi

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import push_state [as 别名]
def test_unsigned_inner_xpi():
    """Test that inner XPIs need to be signed even if not multi-package."""
    xpi = MockXPI(subpackage=True)

    err = ErrorBundle()
    err.supported_versions = {}
    err.push_state('inner.xpi')
    err.save_resource('is_multipackage', False)

    content.test_signed_xpi(err, xpi)

    assert err.failed()
开发者ID:AutomatedTester,项目名称:amo-validator,代码行数:14,代码来源:test_signed_xpi.py

示例5: test_unsigned_inner_jar

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import push_state [as 别名]
def test_unsigned_inner_jar():
    """Test that inner packages don't need to be signed if not multipackage."""
    xpi = MockXPI(subpackage=True)
    xpi.filename = 'mock_jar.jar'

    err = ErrorBundle()
    err.supported_versions = {}
    err.push_state('inner.jar')
    err.save_resource('is_multipackage', False)

    content.test_signed_xpi(err, xpi)

    assert not err.failed()
开发者ID:AutomatedTester,项目名称:amo-validator,代码行数:15,代码来源:test_signed_xpi.py

示例6: test_unsigned_multi_xpi

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import push_state [as 别名]
def test_unsigned_multi_xpi():
    """Test that unsigned inner packages raise an error."""
    xpi = MockXPI(subpackage=True)

    err = ErrorBundle()
    err.supported_versions = {}
    err.push_state('sub.xpi')
    err.save_resource('is_multipackage', True)

    content.test_signed_xpi(err, xpi)

    assert err.failed()
    assert not err.warnings
    assert err.errors
    assert err.errors[0]['id'] == ('testcases_content', 'unsigned_sub_xpi')
开发者ID:AutomatedTester,项目名称:amo-validator,代码行数:17,代码来源:test_signed_xpi.py

示例7: test_mozilla_signed_multi_xpi

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import push_state [as 别名]
def test_mozilla_signed_multi_xpi():
    """Test that mozilla signed inner packages don't raise an error."""
    xpi = MockXPI({
        'META-INF/manifest.mf': 'tests/resources/main/foo.bar',
        'META-INF/mozilla.rsa': 'tests/resources/main/foo.bar',
        'META-INF/mozilla.sf': 'tests/resources/main/foo.bar',
    }, subpackage=True)

    err = ErrorBundle()
    err.supported_versions = {}
    err.push_state('sub.xpi')
    err.save_resource('is_multipackage', True)

    content.test_signed_xpi(err, xpi)

    assert not err.failed()
开发者ID:AutomatedTester,项目名称:amo-validator,代码行数:18,代码来源:test_signed_xpi.py

示例8: test_other_signed_multi_xpi

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import push_state [as 别名]
def test_other_signed_multi_xpi():
    """Test that other signed inner packages raise an error."""
    xpi = MockXPI({
        'META-INF/manifest.mf': 'tests/resources/main/foo.bar',
        'META-INF/zigbert.rsa': 'tests/resources/main/foo.bar',
        'META-INF/zigbert.sf': 'tests/resources/main/foo.bar',
    }, subpackage=True)

    err = ErrorBundle()
    err.supported_versions = {}
    err.push_state('sub.xpi')
    err.save_resource('is_multipackage', True)

    content.test_signed_xpi(err, xpi)

    assert err.failed()
    assert not err.warnings
    assert err.errors
    assert err.errors[0]['id'] == ('testcases_content', 'unsigned_sub_xpi')
开发者ID:AutomatedTester,项目名称:amo-validator,代码行数:21,代码来源:test_signed_xpi.py

示例9: test_states

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import push_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

示例10: test_file_structure

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import push_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

示例11: test_states

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import push_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

示例12: test_file_structure

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import push_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

示例13: test_states

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import push_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.push_state方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。