[py-svn] r35111 - in py/dist/py/test/rsession: . testing webdata
guido at codespeak.net
guido at codespeak.net
Wed Nov 29 11:31:15 CET 2006
Author: guido
Date: Wed Nov 29 11:31:12 2006
New Revision: 35111
Modified:
py/dist/py/test/rsession/testing/test_web.py
py/dist/py/test/rsession/web.py
py/dist/py/test/rsession/webdata/source.js
py/dist/py/test/rsession/webjs.py
Log:
Whitespace and indentation cleanups, fixed bug in parse_args that didn't take
care of unquoting (which I assume will not occur in this webserver, but still...
the webdeveloper in me couldn't ignore this serious problem ;).
Modified: py/dist/py/test/rsession/testing/test_web.py
==============================================================================
--- py/dist/py/test/rsession/testing/test_web.py (original)
+++ py/dist/py/test/rsession/testing/test_web.py Wed Nov 29 11:31:12 2006
@@ -20,3 +20,16 @@
source = rpython2javascript(webjs, FUNCTION_LIST, Options, use_pdb=False)
assert source
+
+def test_parse_args():
+ from py.__.test.rsession.web import TestHandler
+ class TestTestHandler(TestHandler):
+ def __init__(self):
+ pass
+ h = TestTestHandler()
+ assert h.parse_args('foo=bar') == {'foo': 'bar'}
+ assert h.parse_args('foo=bar%20baz') == {'foo': 'bar baz'}
+ assert h.parse_args('foo%20bar=baz') == {'foo bar': 'baz'}
+ assert h.parse_args('foo=bar%baz') == {'foo': 'bar\xbaz'}
+ py.test.raises(ValueError, 'h.parse_args("foo")')
+
Modified: py/dist/py/test/rsession/web.py
==============================================================================
--- py/dist/py/test/rsession/web.py (original)
+++ py/dist/py/test/rsession/web.py Wed Nov 29 11:31:12 2006
@@ -29,7 +29,7 @@
try:
from pypy.rpython.ootypesystem.bltregistry import MethodDesc, BasicExternal,\
- described
+ described
from pypy.translator.js.main import rpython2javascript, Options
from pypy.translator.js import commproxy
@@ -54,8 +54,8 @@
itemtype = item.__class__.__name__
itemname = item.name
fullitemname = "/".join(item.listnames())
- d = {'fullitemname': fullitemname, 'itemtype':itemtype,
- 'itemname':itemname}
+ d = {'fullitemname': fullitemname, 'itemtype': itemtype,
+ 'itemname': itemname}
if itemtype == 'Module':
try:
d['length'] = str(len(list(event.item.tryiter())))
@@ -90,16 +90,19 @@
def show_hosts(self):
self.start_event.wait()
return json.write(self.hosts)
- show_hosts = described(retval={"aa":"aa"})(show_hosts)
+ show_hosts = described(retval={"aa": "aa"})(show_hosts)
def show_skip(self, item_name="aa"):
- return json.write({'item_name':item_name, 'reason':escape(self.skip_reasons[item_name])})
- show_skip = described(retval={"aa":"aa"})(show_skip)
+ return json.write({'item_name': item_name,
+ 'reason': escape(self.skip_reasons[item_name])})
+ show_skip = described(retval={"aa": "aa"})(show_skip)
def show_fail(self, item_name="aa"):
- return json.write({'item_name':item_name, 'traceback':escape(str(self.fail_reasons[item_name])),\
- 'stdout':self.stdout[item_name], 'stderr':self.stderr[item_name]})
- show_fail = described(retval={"aa":"aa"})(show_fail)
+ return json.write({'item_name':item_name,
+ 'traceback':escape(str(self.fail_reasons[item_name])),
+ 'stdout':self.stdout[item_name],
+ 'stderr':self.stderr[item_name]})
+ show_fail = described(retval={"aa": "aa"})(show_fail)
def show_all_statuses(self):
retlist = [self.show_status_change()]
@@ -107,7 +110,7 @@
retlist.append(self.show_status_change())
retval = json.write(retlist)
return retval
- show_all_statuses = described(retval=[{"aa":"aa"}])(show_all_statuses)
+ show_all_statuses = described(retval=[{"aa": "aa"}])(show_all_statuses)
def show_status_change(self):
event = self.pending_events.get()
@@ -128,7 +131,7 @@
if outcome.skipped:
self.skip_reasons[fullitemname] = outcome.skipped
elif outcome.excinfo:
- self.fail_reasons[fullitemname] = self.repr_failure_tblong(\
+ self.fail_reasons[fullitemname] = self.repr_failure_tblong(
event.item, outcome.excinfo, outcome.excinfo.traceback)
self.stdout[fullitemname] = outcome.stdout
self.stderr[fullitemname] = outcome.stderr
@@ -155,7 +158,7 @@
def repr_failure_tblong(self, item, excinfo, traceback):
lines = []
- for index, entry in py.builtin.enumerate(traceback):
+ for index, entry in py.builtin.enumerate(traceback):
lines.append('----------')
lines.append("%s: %s" % (entry.path, entry.lineno))
lines += self.repr_source(entry.relline, entry.source)
@@ -196,7 +199,7 @@
self.pending_events.put(event)
def report(self, what):
- repfun = getattr(self, "report_" + what.__class__.__name__,
+ repfun = getattr(self, "report_" + what.__class__.__name__,
self.report_unknown)
try:
repfun(what)
@@ -240,7 +243,8 @@
if exec_meth is None:
self.send_error(404, "File %s not found" % path)
else:
- self.serve_data('text/json', exec_meth(**self.parse_args(getargs)))
+ self.serve_data('text/json',
+ exec_meth(**self.parse_args(getargs)))
else:
method_to_call()
@@ -249,11 +253,12 @@
if getargs == "":
return {}
+ unquote = py.std.urllib.unquote
args = {}
arg_pairs = getargs.split("&")
for arg in arg_pairs:
key, value = arg.split("=")
- args[key] = value
+ args[unquote(key)] = unquote(value)
return args
def log_message(self, format, *args):
@@ -306,3 +311,4 @@
while not exported_methods.pending_events.empty():
time.sleep(.1)
exported_methods.end_event.wait()
+
Modified: py/dist/py/test/rsession/webdata/source.js
==============================================================================
Binary files. No diff available.
Modified: py/dist/py/test/rsession/webjs.py
==============================================================================
--- py/dist/py/test/rsession/webjs.py (original)
+++ py/dist/py/test/rsession/webjs.py Wed Nov 29 11:31:12 2006
@@ -34,7 +34,7 @@
glob = Pending()
-def comeback(msglist=[{"aa":"aa"}]):
+def comeback(msglist=[{"aa": "aa"}]):
if len(msglist) == 0:
return
for item in glob.pending[:]:
@@ -72,12 +72,14 @@
tr = create_elem("tr")
td = create_elem("td")
tr.appendChild(td)
- td.appendChild(create_text_elem("%s[0/%s]" % (msg['itemname'], msg['length'])))
+ td.appendChild(create_text_elem("%s[0/%s]" % (msg['itemname'],
+ msg['length'])))
max_items[msg['fullitemname']] = int(msg['length'])
short_item_names[msg['fullitemname']] = msg['itemname']
td.id = '_txt_' + msg['fullitemname']
#tr.setAttribute("id", msg['fullitemname'])
- td.setAttribute("onmouseover", "show_info('%s')" % msg['fullitemname'])
+ td.setAttribute("onmouseover", "show_info('%s')" % (
+ msg['fullitemname'],))
td.setAttribute("onmouseout", "hide_info()")
table = create_elem("table")
@@ -97,7 +99,8 @@
return True
td = create_elem("td")
- td.setAttribute("onmouseover", "show_info('%s')" % msg['fullitemname'])
+ td.setAttribute("onmouseover", "show_info('%s')" % (
+ msg['fullitemname'],))
td.setAttribute("onmouseout", "hide_info()")
item_name = msg['fullitemname']
# TODO: dispatch output
@@ -107,15 +110,15 @@
elif msg["skipped"] != 'None':
exported_methods.show_skip(item_name, skip_come_back)
link = create_elem("a")
- link.setAttribute("href", "javascript:show_skip('%s')" % \
- msg['fullitemname'])
+ link.setAttribute("href", "javascript:show_skip('%s')" % (
+ msg['fullitemname'],))
txt = create_text_elem('s')
link.appendChild(txt)
td.appendChild(link)
else:
link = create_elem("a")
- link.setAttribute("href", "javascript:show_traceback('%s')" % \
- msg['fullitemname'])
+ link.setAttribute("href", "javascript:show_traceback('%s')" % (
+ msg['fullitemname'],))
txt = create_text_elem('F')
link.appendChild(txt)
td.appendChild(link)
@@ -128,14 +131,16 @@
name = msg['fullmodulename']
counters[name] += 1
counter_part = get_elem('_txt_' + name)
- counter_part.childNodes[0].nodeValue = "%s[%d/%d]" % \
- (short_item_names[name], counters[name], max_items[name])
+ counter_part.childNodes[0].nodeValue = "%s[%d/%d]" % (
+ short_item_names[name], counters[name], max_items[name])
module_part.childNodes[-1].appendChild(td)
except:
- dom.get_document().getElementById("testmain").innerHTML += "some error"
+ dom.get_document().getElementById("testmain").innerHTML += \
+ "some error"
elif msg['type'] == 'TestFinished':
dom.get_document().title = "Py.test [FINISHED]"
- dom.get_document().getElementById("Tests").childNodes[0].nodeValue = "Tests [FINISHED]"
+ dom.get_document().getElementById("Tests").childNodes[0].nodeValue = \
+ "Tests [FINISHED]"
elif msg['type'] == 'FailedTryiter':
module_part = get_elem(msg['fullitemname'])
if not module_part:
@@ -154,7 +159,7 @@
return True
tr = create_elem("tr")
td = create_elem("td")
- txt = create_text_elem("- skipped (%s)" % msg['reason'])
+ txt = create_text_elem("- skipped (%s)" % (msg['reason'],))
td.appendChild(txt)
tr.appendChild(td)
module_part.appendChild(tr)
@@ -174,8 +179,8 @@
dom.get_document().location = "#message"
def show_traceback(item_name="aa"):
- data = "====== Traceback: =========\n%s\n======== Stdout: ========\n%s\n"\
- "========== Stderr: ==========\n%s\n" % tracebacks[item_name]
+ data = ("====== Traceback: =========\n%s\n======== Stdout: ========\n%s\n"
+ "========== Stderr: ==========\n%s\n" % tracebacks[item_name])
set_msgbox(item_name, data)
def fail_come_back(msg):
More information about the pytest-commit
mailing list