forked from mozilla/amo-validator
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More descriptive error for version issue in Spidermonkey; bug 639584
- Loading branch information
Showing
2 changed files
with
55 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import json | ||
import validator.testcases.javascript.spidermonkey as spidermonkey | ||
|
||
|
||
def test_reflectparse_presence(): | ||
"Tests that when Spidermonkey is too old, a proper error is produced" | ||
|
||
sp = spidermonkey.subprocess | ||
spidermonkey.subprocess = MockSubprocess() | ||
|
||
try: | ||
spidermonkey._get_tree("foo bar", "[path]") | ||
except RuntimeError as err: | ||
print str(err) | ||
assert str(err) == \ | ||
"Spidermonkey version too old; " \ | ||
"1.8pre+ required; error='ReferenceError: [errmsg]'; " \ | ||
"spidermonkey='[path]'" | ||
except: | ||
raise | ||
|
||
spidermonkey.subprocess = sp | ||
|
||
|
||
class MockSubprocess(object): | ||
"A class to mock subprocess" | ||
|
||
def __init__(self): | ||
self.PIPE = True | ||
|
||
def Popen(self, command, shell, stderr, stdout): | ||
return MockSubprocessObject() | ||
|
||
|
||
class MockSubprocessObject(object): | ||
"A class to mock a subprocess object and implement the communicate method" | ||
|
||
def communicate(self): | ||
data = json.dumps({"error": True, | ||
"error_message": "ReferenceError: [errmsg]"}) | ||
return data, "" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters