本文整理汇总了Python中validator.decorator.version_range函数的典型用法代码示例。如果您正苦于以下问题:Python version_range函数的具体用法?Python version_range怎么用?Python version_range使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了version_range函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_fx13_interfaces
def test_fx13_interfaces():
"""
Test that the Gecko 13 compatibility warnings and errors for matched
patterns are thrown when they're supposed to.
"""
err = _do_real_test_raw("""
var x = Components.interfaces.nsILivemarkService;
""", versions={FIREFOX_GUID: version_range("firefox", "13.0a1")})
assert not err.failed(fail_on_warnings=False)
assert err.compat_summary["errors"]
err = _do_real_test_raw("""
var x = Components.interfaces.nsIPrefBranch2;
""", versions={FIREFOX_GUID: version_range("firefox", "13.0a1")})
assert not err.failed(fail_on_warnings=False)
assert err.compat_summary["warnings"]
err = _do_real_test_raw("""
var x = Components.interfaces.nsIScriptableUnescapeHTML;
""", versions={FIREFOX_GUID: version_range("firefox", "13.0a1")})
assert not err.failed(fail_on_warnings=False)
assert err.compat_summary["warnings"]
err = _do_real_test_raw("""
var x = Components.interfaces.nsIAccessNode;
""", versions={FIREFOX_GUID: version_range("firefox", "13.0a1")})
assert not err.failed(fail_on_warnings=False)
assert err.compat_summary["errors"]
示例2: test_fx7_nsIDOMFile
def test_fx7_nsIDOMFile():
"""Test that nsIDOMFile methods are flagged."""
err = _do_real_test_raw("""
var x = Components.classes.createInstance(
Components.interfaces.nsIDOMFile);
x.getAsBinary();
""")
assert not err.failed()
assert not err.notices
assert not any(err.compat_summary.values())
err = _do_real_test_raw("""
var x = Components.classes["foo"].createInstance(
Components.interfaces.nsIDOMFile);
x.getAsDataURL();
""", versions={'{ec8030f7-c20a-464f-9b0e-13a3a9e97384}':
version_range("firefox", "7.0a1")})
assert not err.failed()
assert len(err.notices) == 1
assert err.compat_summary["errors"]
err = _do_real_test_raw("""
var x = document.getElementById("whatever");
x.getAsDataURL();
""", versions={'{ec8030f7-c20a-464f-9b0e-13a3a9e97384}':
version_range("firefox", "7.0a1")})
assert not err.failed()
assert len(err.notices) == 1
assert err.compat_summary["errors"]
示例3: test_window_top
def test_window_top():
"""
Test that 'window.top' (a reserved global variable as of Firefox 6) is
flagged as incompatible.
"""
err = _do_real_test_raw("""
window.top = "foo";
top = "bar";
""")
print err.print_summary(verbose=True)
assert not err.failed()
assert not err.notices
err = _do_real_test_raw("""
window.top = "foo";
""", versions={'{ec8030f7-c20a-464f-9b0e-13a3a9e97384}':
version_range("firefox", "6.0a1")})
print err.print_summary(verbose=True)
assert not err.failed()
assert err.notices
assert err.compat_summary["warnings"]
err = _do_real_test_raw("""
top = "foo";
""", versions={'{ec8030f7-c20a-464f-9b0e-13a3a9e97384}':
version_range("firefox", "6.0a1")})
print err.print_summary(verbose=True)
assert not err.failed()
assert err.notices
assert err.compat_summary["warnings"]
示例4: test_fx7_nsIDOMFile
def test_fx7_nsIDOMFile():
"""Test that nsIDOMFile methods are flagged."""
err = _do_real_test_raw("""
var x = Components.classes.createInstance(
Components.interfaces.nsIDOMFile);
x.getAsBinary();
""")
assert not err.failed(fail_on_warnings=False)
assert not err.notices
assert not any(err.compat_summary.values())
err = _do_real_test_raw("""
var x = Components.classes["foo"].createInstance(
Components.interfaces.nsIDOMFile);
x.getAsDataURL();
""", versions={FIREFOX_GUID: version_range("firefox", "7.0a1")})
assert not err.failed(fail_on_warnings=False)
assert len(err.notices) == 1
assert err.compat_summary["errors"]
err = _do_real_test_raw("""
var x = document.getElementById("whatever");
x.getAsDataURL();
""", versions={FIREFOX_GUID: version_range("firefox", "7.0a1")})
assert not err.failed()
assert len(err.notices) == 1
assert err.compat_summary["errors"]
示例5: amp_rp_bug660359
def amp_rp_bug660359(wrapper, arguments, traverser):
"""
Flag all calls to AddonManagerPrivate.registerProvider for incompatibility
with Firefox 6.
"""
traverser.err.notice(
err_id=("testcases_javascript_calldefinitions",
"amp_rp_bug660359"),
notice="Custom add-on types may not work properly in Firefox 6",
description="This add-on appears to register custom add-on types, "
"which are affected and may not work properly due to "
"changes made on Firefox 6. For more information, "
"please refer to "
"https://bugzilla.mozilla.org/show_bug.cgi?id=595848",
filename=traverser.filename,
line=traverser.line,
column=traverser.position,
context=traverser.context,
for_appversions={'{ec8030f7-c20a-464f-9b0e-13a3a9e97384}':
version_range("firefox", "6.0a1", "7.0a1"),
'{3550f703-e582-4d05-9a08-453d09bdfdc6}':
version_range("thunderbird", "6.0a1", "7.0a1"),},
compatibility_type="error",
tier=5)
示例6: document_getSelection
def document_getSelection(wrapper, arguments, traverser):
"""Flag Firefox 8 calls to document.getSelection()."""
MDN_ARTICLE = "https://developer.mozilla.org/En/Window.getSelection"
traverser.err.notice(
err_id=("testcases_javascript_calldefinitions", "document_getSel"),
notice="document.getSelection()'s return type has changed.",
description="The return type of document.getSelection() has changed "
"in Firefox 8. This function is deprecated, and you "
"should be using window.getSelection() instead. See "
"%s for more information." % MDN_ARTICLE,
filename=traverser.filename,
line=traverser.line,
column=traverser.position,
context=traverser.context,
compatibility_type="error",
for_appversions={'{ec8030f7-c20a-464f-9b0e-13a3a9e97384}':
version_range("firefox", "8.0a1", "9.0a1"),
'{3550f703-e582-4d05-9a08-453d09bdfdc6}':
version_range("thunderbird", "8.0a1", "9.0a1"),},
tier=5)
# The new spec returns an object.
return JSWrapper(JSObject(), traverser=traverser)
示例7: test_tb7_deRDF_addressbook
def test_tb7_deRDF_addressbook():
"""Test that addressbook rdf sources are flagged"""
err = _do_real_test_raw("""
var x = 'datasources="rdf:addressdirectory" ref="moz-abdirectory://"';
""")
assert not err.failed()
assert not err.notices
err = _do_real_test_raw("""
var x = 'datasources="rdf:addressdirectory" ref="moz-abdirectory://"';
""", versions={TB_GUID: version_range("thunderbird", "7.0a1")})
assert not err.failed()
assert err.notices
assert err.compat_summary["errors"]
err = _do_real_test_raw("""
var x = 'GetResource(SomeText).QueryInterface(6inTestxnsIAbDirectory);';
""")
assert not err.failed()
assert not err.notices
err = _do_real_test_raw("""
var x = "GetResource(SomeText).QueryInterface(Some8678StuffnsIAbDirectory)";
""", versions={TB_GUID: version_range("thunderbird", "7.0a1")})
assert not err.failed()
assert err.notices
assert err.compat_summary["errors"]
示例8: test_version_range_before
def test_version_range_before():
"""Test the `before` parameter of version_range."""
new_versions = {"1": {"guid": "foo",
"versions": map(str, range(10))}}
eq_(version_range("foo", "5", "6", app_versions=new_versions), ["5"])
eq_(version_range("foo", "8", "50", app_versions=new_versions), ["8", "9"])
示例9: test_version_range_before
def test_version_range_before():
"""Test the `before` parameter of version_range."""
new_versions = {'1': {'guid': 'foo',
'versions': map(str, range(10))}}
assert decorator.version_range('foo', '5', '6', app_versions=new_versions) == ['5']
assert decorator.version_range('foo', '8', '50', app_versions=new_versions) == ['8', '9']
示例10: test_version_range
def test_version_range():
"""
Tests that the appropriate versions after the specified versions are
returned.
"""
new_versions = {'1': {'guid': 'foo',
'versions': map(str, range(10))}}
assert decorator.version_range('foo', '8', app_versions=new_versions) == ['8', '9']
assert decorator.version_range('foo', '5', app_versions=new_versions) == ['5', '6', '7', '8', '9']
示例11: test_version_range
def test_version_range():
"""
Tests that the appropriate versions after the specified versions are
returned.
"""
new_versions = {"1": {"guid": "foo",
"versions": map(str, range(10))}}
eq_(version_range("foo", "8", app_versions=new_versions), ["8", "9"])
eq_(version_range("foo", "5", app_versions=new_versions),
["5", "6", "7", "8", "9"])
示例12: test_requestAnimationFrame
def test_requestAnimationFrame():
"""
Test that requestAnimationFrame requires at least one parameter.
"""
err = _do_real_test_raw("""
requestAnimationFrame(foo);
""", versions={FIREFOX_GUID: version_range("firefox", "11.0a1")})
assert not err.failed()
err = _do_real_test_raw("""
requestAnimationFrame();
""", versions={FIREFOX_GUID: version_range("firefox", "11.0a1")})
assert err.failed()
assert err.compat_summary["errors"]
示例13: test_fx9_nsIBrowserHistory_removePages
def test_fx9_nsIBrowserHistory_removePages():
"""
nsIBrowserHistory.removePages() takes 2 arguments instead of 3 in
Firefox 9.
"""
futureCompatError(
"""
var browserHistory = Components.classes[
"@mozilla.org/browser/global-history;2"]
.getService(
Components.interfaces.nsIBrowserHistory);
browserHistory.removePages(uriList, uriList.length, false);
""",
'9.0a1')
err = _do_real_test_raw(
"""
var browserHistory = Components.classes[
"@mozilla.org/browser/global-history;2"]
.getService(
Components.interfaces.nsIBrowserHistory);
browserHistory.removePages(uriList, uriList.length);
""",
versions={FIREFOX_GUID: version_range("firefox", "9.0a1")})
assert not err.failed(fail_on_warnings=False)
assert not err.compat_summary["errors"]
示例14: test_tb12_compatibility
def test_tb12_compatibility():
"""
Test that the changed/removed interfaces for Thunderbird 12 are flagged.
"""
err = _do_real_test_raw("""
var x = Components.classes["foo"].createInstance(
Components.interfaces.nsIMsgDBService);
x.openMailDBFromFile();
var y = Components.classes["foo"].createInstance(
Components.interfaces.nsIMsgDatabase);
y.Open();
""")
assert not err.failed(fail_on_warnings=False)
assert not err.warnings
assert not any(err.compat_summary.values())
err = _do_real_test_raw("""
var x = Components.classes["foo"].createInstance(
Components.interfaces.nsIMsgDBService);
x.openMailDBFromFile();
var y = Components.classes["foo"].createInstance(
Components.interfaces.nsIMsgDatabase);
y.Open();
""", versions={TB_GUID: version_range("thunderbird", "12.0a1")})
assert err.failed
assert len(err.notices) == 2
assert err.compat_summary["errors"]
示例15: test_fx9_nsIURLParser_parsePath
def test_fx9_nsIURLParser_parsePath():
"""
nsIURLParser.parsePath takes 8 args instead of 10 now.
"""
futureCompatError(
"""
var URLi = Components.classes[
"@mozilla.org/network/url-parser;1?auth=maybe"].
createInstance(Components.interfaces.nsIURLParser);
var filepathPos = {}, filepathLen = {}, paramPos = {}, paramLen = {},
queryPos = {}, queryLen = {}, refPos = {}, refLen = {};
URLi.parsePath(urlObj.path, -1, filepathPos, filepathLen, paramPos,
paramLen, queryPos, queryLen, refPos, refLen);
""",
'9.0a1')
err = _do_real_test_raw(
"""
var URLi = Components.classes[
"@mozilla.org/network/url-parser;1?auth=maybe"].
createInstance(Components.interfaces.nsIURLParser);
var filepathPos = {}, filepathLen = {}, queryPos = {}, queryLen = {},
refPos = {}, refLen = {};
URLi.parsePath(urlObj.path, -1, filepathPos, filepathLen, queryPos,
queryLen, refPos, refLen);
""",
versions={FIREFOX_GUID: version_range("firefox", "9.0a1")})
assert not err.failed(fail_on_warnings=False)
assert not err.compat_summary["errors"]