Merge lp:~lazr-developers/lazr.testing/jstestdriver-1.2.2 into lp:lazr.testing

Proposed by Sidnei da Silva
Status: Merged
Approved by: Martin Albisetti
Approved revision: 33
Merged at revision: 31
Proposed branch: lp:~lazr-developers/lazr.testing/jstestdriver-1.2.2
Merge into: lp:lazr.testing
Diff against target: 416 lines (+126/-114)
6 files modified
buildout.cfg (+9/-11)
src/lazr/testing/browser_wrapper.py (+1/-3)
src/lazr/testing/jstestdriver.py (+47/-22)
src/lazr/testing/tests/jstestdriver.txt (+67/-77)
src/lazr/testing/tests/test_js.py (+1/-0)
src/lazr/testing/version.txt (+1/-1)
To merge this branch: bzr merge lp:~lazr-developers/lazr.testing/jstestdriver-1.2.2
Reviewer Review Type Date Requested Status
Martin Albisetti (community) Approve
Review via email: [email protected]

Description of the change

A few minor adjustments to make it work with JsTestDriver 1.2.2. Unfortunately, breaks compatibility with JsTestDriver 1.1.

To post a comment you must log in.
32. By Sidnei da Silva

- Add some comments to explain changes. Actually make the tests pass.

33. By Sidnei da Silva

- Error message snafu.

Revision history for this message
Martin Albisetti (beuno) wrote :

Looks good, tests pass in lazr-js!

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'buildout.cfg'
2--- buildout.cfg 2009-10-16 18:30:05 +0000
3+++ buildout.cfg 2010-06-18 02:08:25 +0000
4@@ -19,9 +19,6 @@
5
6 allow-picked-versions = false
7
8-allowed-eggs-from-site-packages =
9-include-site-packages-for-buildout = false
10-
11 prefer-final = true
12
13 versions = versions
14@@ -30,23 +27,24 @@
15
16 [versions]
17 # Alphabetical, case-sensitive, please! :-)
18-docutils = 0.5
19-Jinja2 = 2.2.1
20+distribute = 0.6.10
21+docutils = 0.6
22+Jinja2 = 2.3.1
23 logilab.pylintinstaller = 0.15.2
24 mocker = 0.10.1
25-Pygments = 1.1.1
26+Pygments = 1.3.1
27 pylint = 0.15.2
28-Sphinx = 0.6.3
29+Sphinx = 0.6.5
30 setuptools = 0.6c9
31 z3c.recipe.filetemplate = 2.0.3
32 z3c.recipe.sphinxdoc = 0.0.8
33 z3c.recipe.tag = 0.3.0
34-zc.buildout = 1.5.0dev-gary-r103553
35-zc.recipe.egg = 1.3.0dev-gary-r103515
36+zc.buildout = 1.5.0dev-gary-r111190
37+zc.recipe.egg = 1.2.3dev-gary-r110068
38 zc.recipe.testrunner = 1.2.0
39 zope.exceptions = 3.5.2
40-zope.interface = 3.5.1
41-zope.testing = 3.8.3
42+zope.interface = 3.5.3
43+zope.testing = 3.9.4-bug579019
44
45
46 [test]
47
48=== modified file 'src/lazr/testing/browser_wrapper.py'
49--- src/lazr/testing/browser_wrapper.py 2009-10-16 18:30:05 +0000
50+++ src/lazr/testing/browser_wrapper.py 2010-06-18 02:08:25 +0000
51@@ -1,10 +1,8 @@
52 #!/usr/bin/env python
53
54-import os
55 import sys
56 import webbrowser
57
58 if __name__ == "__main__":
59 if len(sys.argv) == 2:
60- browser = os.environ.get("LANDSCAPE_BROWSER")
61- webbrowser.get(browser).open(sys.argv[1])
62+ webbrowser.get().open(sys.argv[1])
63
64=== modified file 'src/lazr/testing/jstestdriver.py'
65--- src/lazr/testing/jstestdriver.py 2009-10-16 19:11:28 +0000
66+++ src/lazr/testing/jstestdriver.py 2010-06-18 02:08:25 +0000
67@@ -34,7 +34,8 @@
68 self.name = name
69 self.browser = browser
70 self.duration = duration
71- self.message = []
72+ self.message = None
73+ self.content = []
74
75 def countTestCases(self):
76 return 1
77@@ -43,7 +44,7 @@
78 return None
79
80 def id(self):
81- return "%s.%s:%s" % (self.classname, self.name, self.browser)
82+ return "%s.%s.%s" % (self.browser, self.classname, self.name)
83
84 def __str__(self):
85 return "%s:%s (%s)" % (self.name, self.browser, self.classname)
86@@ -59,7 +60,6 @@
87 def __init__(self, name, test_id):
88 self.name = name
89 self.test_id = test_id
90- self.message = []
91
92 def countTestCases(self):
93 return 1
94@@ -103,16 +103,17 @@
95 if tag == "testsuite":
96 pass
97 elif tag == "testcase":
98- classname = attributes["classname"]
99- name, browser = attributes["name"].split(":", 1)
100+ browser, classname = attributes["classname"].split(".", 1)
101+ name = attributes["name"]
102 duration = attributes["time"]
103 self.test_result = JsTestDriverResult(classname, name,
104 browser, duration)
105 self.result.startTest(self.test_result)
106- elif tag == "error":
107- self.test_result.error_message = attributes["message"]
108- elif tag == "failure":
109+ elif tag in ("error", "failure"):
110 self.test_result.failure_type = attributes["type"]
111+ message = attributes.get("message", None)
112+ if message is not None:
113+ self.test_result.message = message
114 else:
115 raise ValueError("Unexpected tag: %s" % tag)
116
117@@ -127,13 +128,23 @@
118 self.result.addSuccess(self.test_result)
119 self.result.stopTest(self.test_result)
120 elif tag == "error":
121+ message = self.test_result.message
122+ if message is None:
123+ message = self.test_result.content
124+ else:
125+ message = [message]
126 try:
127- raise JsTestDriverError(self.test_result.message)
128+ raise JsTestDriverError(message)
129 except:
130 self.result.addError(self.test_result, sys.exc_info())
131 elif tag == "failure":
132+ message = self.test_result.message
133+ if message is None:
134+ message = self.test_result.content
135+ else:
136+ message = [message]
137 try:
138- raise JsTestDriverFailure(self.test_result.message)
139+ raise JsTestDriverFailure(message)
140 except:
141 self.result.addFailure(self.test_result, sys.exc_info())
142 else:
143@@ -141,7 +152,7 @@
144
145 def CharacterDataHandler(self, data):
146 if self.test_result is not None:
147- self.test_result.message.append(data)
148+ self.test_result.content.append(data)
149
150
151 def startJsTestDriver():
152@@ -150,11 +161,18 @@
153
154 capture_timeout = int(os.environ.get(
155 "JSTESTDRIVER_CAPTURE_TIMEOUT", "30"))
156- browser = os.environ.get(
157- "BROWSER",
158- os.path.join(os.path.dirname(__file__), "browser_wrapper.py"))
159-
160- cmd = jstestdriver.split() + ["--port", port]
161+
162+ # With JsTestDriver 1.2.2 no messages are printed unless
163+ # --runnerMode=INFO.
164+ cmd = jstestdriver.split() + ["--port", port, "--runnerMode", "INFO"]
165+
166+ # By default we run the tests with the preferred browser
167+ # configured at the OS level. This is done by using the webbrowser
168+ # module, through browser_wrapper.py.
169+ browser = os.environ.get("JSTESTDRIVER_BROWSER", "default")
170+ if browser == "default":
171+ browser = os.path.join(os.path.dirname(__file__), "browser_wrapper.py")
172+
173 if browser:
174 cmd.extend(["--browser", browser])
175
176@@ -277,16 +295,23 @@
177 stdout=subprocess.PIPE,
178 stderr=subprocess.PIPE)
179 stdout, stderr = proc.communicate()
180- if proc.returncode != 0:
181+ # JsTestDriver 1.2.2 outputs this message to stdout when the
182+ # actual tests failed. It also returns an error code. Only
183+ # raise an error if the tests did not run at all, but not if
184+ # they just failed.
185+ if proc.returncode != 0 and not "Tests failed." in stdout:
186 raise ValueError(
187 "Failed to execute JsTestDriver tests for:\n"
188 "%s (%s)\nError: %s" %
189 (self.config_filename, server, stderr))
190 if stderr:
191- test_result = GlobalJsTestDriverResult(str(self), self.id())
192- result.startTest(test_result)
193- result.addFailure(
194- test_result, (RuntimeError, RuntimeError(stderr), None))
195+ # JsTestDriver 1.2.2 outputs this message for a successful
196+ # run with --runnerMode=INFO.
197+ if not "Finished action run." in stderr:
198+ test_result = GlobalJsTestDriverResult(str(self), self.id())
199+ result.startTest(test_result)
200+ result.addFailure(
201+ test_result, (RuntimeError, RuntimeError(stderr), None))
202
203 def _reportResults(self, result):
204 """Parse generated test results and report them to L{unittest}.
205@@ -299,7 +324,7 @@
206 output.close()
207
208 expat = xml.parsers.expat.ParserCreate()
209- parser = JsTestDriverResultParser(expat, result)
210+ JsTestDriverResultParser(expat, result)
211 expat.Parse(body, 1)
212
213 def run(self, result=None):
214
215=== modified file 'src/lazr/testing/tests/jstestdriver.txt'
216--- src/lazr/testing/tests/jstestdriver.txt 2009-10-16 19:11:28 +0000
217+++ src/lazr/testing/tests/jstestdriver.txt 2010-06-18 02:08:25 +0000
218@@ -30,67 +30,13 @@
219 Running lazr.testing.jstestdriver.JsTestDriverLayer tests:
220 Set up lazr.testing.jstestdriver.JsTestDriverLayer in N.NNN seconds.
221 Running:
222- runTest (lazr.testing.tests.test_js.JsTestDriverSelfTest) (N.NNN s)
223- <BLANKLINE>
224- <BLANKLINE>
225- Failure in test runTest (lazr.testing.tests.test_js.JsTestDriverSelfTest)
226- Traceback (most recent call last):
227- RuntimeError: error loading file: .../src/lazr/testing/tests/js/test_load.js:1 missing ; before statement
228- <BLANKLINE>
229- <BLANKLINE>
230- <BLANKLINE>
231- testAssertEquals:BrowserN.N.N.N (FailureTestCase) (N.NNN s)
232- <BLANKLINE>
233- <BLANKLINE>
234- Failure in test testAssertEquals:BrowserN.N.N.N (FailureTestCase)
235- Traceback (most recent call last):
236- ...
237- JsTestDriverFailure: expected "Hello" but was "World!"
238- <BLANKLINE>
239- (N.NNN s)
240- testAssertTrue:BrowserN.N.N.N (FailureTestCase) (N.NNN s)
241- <BLANKLINE>
242- <BLANKLINE>
243- Failure in test testAssertTrue:BrowserN.N.N.N (FailureTestCase)
244- Traceback (most recent call last):
245- ...
246- JsTestDriverFailure: How can that possibly be false? expected true but was false
247- <BLANKLINE>
248- (N.NNN s)
249- testAssertFalse:BrowserN.N.N.N (FailureInlineTestCase) (N.NNN s)
250- <BLANKLINE>
251- <BLANKLINE>
252- Failure in test testAssertFalse:BrowserN.N.N.N (FailureInlineTestCase)
253- Traceback (most recent call last):
254- ...
255- JsTestDriverFailure: Not false? Are you kidding me? expected false but was true
256- <BLANKLINE>
257- (N.NNN s)
258- testAssertNull:BrowserN.N.N.N (FailureInlineTestCase) (N.NNN s)
259- <BLANKLINE>
260- <BLANKLINE>
261- Failure in test testAssertNull:BrowserN.N.N.N (FailureInlineTestCase)
262- Traceback (most recent call last):
263- ...
264- JsTestDriverFailure: I was pretty sure it was null. expected null but was {}
265- <BLANKLINE>
266- (N.NNN s)
267- testAssertEquals:BrowserN.N.N.N (ErrorTestCase) (N.NNN s)
268- <BLANKLINE>
269- <BLANKLINE>
270- Error in test testAssertEquals:BrowserN.N.N.N (ErrorTestCase)
271- Traceback (most recent call last):
272- ...
273- JsTestDriverError: y is not defined
274- <BLANKLINE>
275- (N.NNN s)
276- testAssertTrue:BrowserN.N.N.N (ErrorTestCase) (N.NNN s)
277- <BLANKLINE>
278- <BLANKLINE>
279- Error in test testAssertTrue:BrowserN.N.N.N (ErrorTestCase)
280- Traceback (most recent call last):
281- ...
282- JsTestDriverError: y is not defined
283+ testThrowAFit:BrowserN.N.N.N (ErrorInlineTestCase) (N.NNN s)
284+ <BLANKLINE>
285+ <BLANKLINE>
286+ Error in test testThrowAFit:BrowserN.N.N.N (ErrorInlineTestCase)
287+ Traceback (most recent call last):
288+ ...
289+ JsTestDriverError: "A Fit"
290 <BLANKLINE>
291 (N.NNN s)
292 testAssertFalse:BrowserN.N.N.N (ErrorInlineTestCase) (N.NNN s)
293@@ -111,15 +57,6 @@
294 JsTestDriverError: y is not defined
295 <BLANKLINE>
296 (N.NNN s)
297- testThrowAFit:BrowserN.N.N.N (ErrorInlineTestCase) (N.NNN s)
298- <BLANKLINE>
299- <BLANKLINE>
300- Error in test testThrowAFit:BrowserN.N.N.N (ErrorInlineTestCase)
301- Traceback (most recent call last):
302- ...
303- JsTestDriverError: "A Fit"
304- <BLANKLINE>
305- (N.NNN s)
306 testThrowAnError:BrowserN.N.N.N (ErrorInlineTestCase) (N.NNN s)
307 <BLANKLINE>
308 <BLANKLINE>
309@@ -129,28 +66,81 @@
310 JsTestDriverError: Some Messy Message
311 <BLANKLINE>
312 (N.NNN s)
313+ testAssertFalse:BrowserN.N.N.N (FailureInlineTestCase) (N.NNN s)
314+ <BLANKLINE>
315+ <BLANKLINE>
316+ Failure in test testAssertFalse:BrowserN.N.N.N (FailureInlineTestCase)
317+ Traceback (most recent call last):
318+ ...
319+ JsTestDriverFailure: Not false? Are you kidding me? expected false but was true
320+ <BLANKLINE>
321+ (N.NNN s)
322+ testAssertNull:BrowserN.N.N.N (FailureInlineTestCase) (N.NNN s)
323+ <BLANKLINE>
324+ <BLANKLINE>
325+ Failure in test testAssertNull:BrowserN.N.N.N (FailureInlineTestCase)
326+ Traceback (most recent call last):
327+ ...
328+ JsTestDriverFailure: I was pretty sure it was null. expected null but was {}
329+ <BLANKLINE>
330+ (N.NNN s)
331 testAssertEquals:BrowserN.N.N.N (SuccessTestCase) (N.NNN s)
332 testAssertTrue:BrowserN.N.N.N (SuccessTestCase) (N.NNN s)
333 testAssertFalse:BrowserN.N.N.N (SuccessInlineTestCase) (N.NNN s)
334 testAssertNull:BrowserN.N.N.N (SuccessInlineTestCase) (N.NNN s)
335- Ran 15 tests with 5 failures and 6 errors in N.NNN seconds.
336+ testAssertEquals:BrowserN.N.N.N (FailureTestCase) (N.NNN s)
337+ <BLANKLINE>
338+ <BLANKLINE>
339+ Failure in test testAssertEquals:BrowserN.N.N.N (FailureTestCase)
340+ Traceback (most recent call last):
341+ ...
342+ JsTestDriverFailure: expected "Hello" but was "World!"
343+ <BLANKLINE>
344+ (N.NNN s)
345+ testAssertTrue:BrowserN.N.N.N (FailureTestCase) (N.NNN s)
346+ <BLANKLINE>
347+ <BLANKLINE>
348+ Failure in test testAssertTrue:BrowserN.N.N.N (FailureTestCase)
349+ Traceback (most recent call last):
350+ ...
351+ JsTestDriverFailure: How can that possibly be false? expected true but was false
352+ <BLANKLINE>
353+ (N.NNN s)
354+ testAssertEquals:BrowserN.N.N.N (ErrorTestCase) (N.NNN s)
355+ <BLANKLINE>
356+ <BLANKLINE>
357+ Error in test testAssertEquals:BrowserN.N.N.N (ErrorTestCase)
358+ Traceback (most recent call last):
359+ ...
360+ JsTestDriverError: y is not defined
361+ <BLANKLINE>
362+ (N.NNN s)
363+ testAssertTrue:BrowserN.N.N.N (ErrorTestCase) (N.NNN s)
364+ <BLANKLINE>
365+ <BLANKLINE>
366+ Error in test testAssertTrue:BrowserN.N.N.N (ErrorTestCase)
367+ Traceback (most recent call last):
368+ ...
369+ JsTestDriverError: y is not defined
370+ <BLANKLINE>
371+ (N.NNN s)
372+ Ran 14 tests with 4 failures and 6 errors in N.NNN seconds.
373 Tearing down left over layers:
374 Tear down lazr.testing.jstestdriver.JsTestDriverLayer in N.NNN seconds.
375 <BLANKLINE>
376 Tests with errors:
377- testAssertEquals:BrowserN.N.N.N (ErrorTestCase)
378- testAssertTrue:BrowserN.N.N.N (ErrorTestCase)
379+ testThrowAFit:BrowserN.N.N.N (ErrorInlineTestCase)
380 testAssertFalse:BrowserN.N.N.N (ErrorInlineTestCase)
381 testAssertNull:BrowserN.N.N.N (ErrorInlineTestCase)
382- testThrowAFit:BrowserN.N.N.N (ErrorInlineTestCase)
383 testThrowAnError:BrowserN.N.N.N (ErrorInlineTestCase)
384+ testAssertEquals:BrowserN.N.N.N (ErrorTestCase)
385+ testAssertTrue:BrowserN.N.N.N (ErrorTestCase)
386 <BLANKLINE>
387 Tests with failures:
388- runTest (lazr.testing.tests.test_js.JsTestDriverSelfTest)
389+ testAssertFalse:BrowserN.N.N.N (FailureInlineTestCase)
390+ testAssertNull:BrowserN.N.N.N (FailureInlineTestCase)
391 testAssertEquals:BrowserN.N.N.N (FailureTestCase)
392 testAssertTrue:BrowserN.N.N.N (FailureTestCase)
393- testAssertFalse:BrowserN.N.N.N (FailureInlineTestCase)
394- testAssertNull:BrowserN.N.N.N (FailureInlineTestCase)
395 True
396
397 >>> del os.environ["JSTESTDRIVER_SELFTEST"]
398
399=== modified file 'src/lazr/testing/tests/test_js.py'
400--- src/lazr/testing/tests/test_js.py 2009-10-16 19:11:28 +0000
401+++ src/lazr/testing/tests/test_js.py 2010-06-18 02:08:25 +0000
402@@ -159,6 +159,7 @@
403 (re.compile(r"\d+[.]\d\d\d s"), "N.NNN s"),
404 (re.compile(r"\d+[.]\d\d\d{"), "N.NNN{"),
405 (re.compile(r":\w+[\d\.]+ "), ":BrowserN.N.N.N "),
406+ (re.compile(r":\w+_\d+_\w+ "), ":BrowserN.N.N.N "),
407
408 # omit traceback entries for jstestdriver.py or doctest.py from
409 # output:
410
411=== modified file 'src/lazr/testing/version.txt'
412--- src/lazr/testing/version.txt 2009-10-16 20:22:46 +0000
413+++ src/lazr/testing/version.txt 2010-06-18 02:08:25 +0000
414@@ -1,1 +1,1 @@
415-0.1.1
416+0.1.2

Subscribers

People subscribed via source and target branches

to all changes: