2 new revisions:
Revision: 22f65b78cfd9
Branch: default
Author: Robot Framework Developers (robotframew...@gmail.com)
Date: Thu Sep 19 09:06:33 2013 UTC
Log: whitespace
http://code.google.com/p/robotframework/source/detail?r=22f65b78cfd9
Revision: 41ff06999c8a
Branch: default
Author: Robot Framework Developers (robotframew...@gmail.com)
Date: Thu Sep 19 09:21:15 2013 UTC
Log: Dump text data to outputs as UTF-8 to avoid the need to escape
non-ACI...
http://code.google.com/p/robotframework/source/detail?r=41ff06999c8a
==============================================================================
Revision: 22f65b78cfd9
Branch: default
Author: Robot Framework Developers (robotframew...@gmail.com)
Date: Thu Sep 19 09:06:33 2013 UTC
Log: whitespace
http://code.google.com/p/robotframework/source/detail?r=22f65b78cfd9
Modified:
/utest/htmldata/test_jsonwriter.py
=======================================
--- /utest/htmldata/test_jsonwriter.py Tue Mar 6 09:54:21 2012 UTC
+++ /utest/htmldata/test_jsonwriter.py Thu Sep 19 09:06:33 2013 UTC
@@ -48,19 +48,19 @@
self._test(0L, '0')
def test_dump_list(self):
-
self._test([1,2,True, 'hello', 'world'], '[1,2,true,"hello","world"]')
- self._test(['*nes"ted', [1,2,[4]]], '["*nes\\"ted",[1,2,[4]]]')
+ self._test([1, 2,
True, 'hello', 'world'], '[1,2,true,"hello","world"]')
+ self._test(['*nes"ted', [1, 2, [4]]], '["*nes\\"ted",[1,2,[4]]]')
def test_dump_tuple(self):
self._test(('hello', '*world'), '["hello","*world"]')
- self._test((1,2,(3,4)), '[1,2,[3,4]]')
+ self._test((1, 2, (3, 4)), '[1,2,[3,4]]')
def test_dump_dictionary(self):
self._test({'key': 1}, '{"key":1}')
self._test({'nested': [-1L, {42:
None}]}, '{"nested":[-1,{42:null}]}')
def test_dictionaries_are_sorted(self):
- self._test({'key':1, 'hello':['wor','ld'], 'z': 'a', 'a': 'z'},
+ self._test({'key': 1, 'hello': ['wor', 'ld'], 'z': 'a', 'a': 'z'},
'{"a":"z","hello":["wor","ld"],"key":1,"z":"a"}')
def test_dump_none(self):
@@ -72,8 +72,8 @@
mapped1 = object()
mapped2 = 'string'
dumper.dump([mapped1, [mapped2, {mapped2: mapped1}]],
- mapping={mapped1:'1', mapped2:'a'})
- assert_equals(output.getvalue(), '[1,[a,{a:1}]]')
+ mapping={mapped1: '1', mapped2: 'a'})
+ assert_equals(output.getvalue(), '[1,[a,{a:1}]]')
assert_raises(ValueError, dumper.dump, [mapped1])
if json:
==============================================================================
Revision: 41ff06999c8a
Branch: default
Author: Robot Framework Developers (robotframew...@gmail.com)
Date: Thu Sep 19 09:21:15 2013 UTC
Log: Dump text data to outputs as UTF-8 to avoid the need to escape
non-ACII chars.
This fixes dumping characters outside the Unicode BMP and seems to have also
better performance characteristics.
Update issue 1526
Status: Started
Owner: pekka.klarck
Implemented and updated affected tests.
http://code.google.com/p/robotframework/source/detail?r=41ff06999c8a
Modified:
/atest/robot/testdoc/testdoc.txt
/src/robot/htmldata/jsonwriter.py
/utest/htmldata/test_jsonwriter.py
=======================================
--- /atest/robot/testdoc/testdoc.txt Mon May 13 23:25:58 2013 UTC
+++ /atest/robot/testdoc/testdoc.txt Thu Sep 19 09:21:15 2013 UTC
@@ -25,7 +25,7 @@
Many inputs
${output}= Run TestDoc --exclude t1 --title Nön-ÄSCII ${INPUT 1}
${INPUT2} ${INPUT 3}
- Testdoc Should Contain "name":"Pass And Fail & Suites &
Testdoc" "title":"N\\u00f6n-\\u00c4SCII" "numberOfTests":7
+ Testdoc Should Contain "name":"Pass And Fail & Suites &
Testdoc" "title":"Nön-ÄSCII" "numberOfTests":7
Testdoc Should Not Contain "name":"Suite4 First"
Outfile Should Have Correct Line Separators
Output Should Contain Outfile ${output}
=======================================
--- /src/robot/htmldata/jsonwriter.py Thu Jun 6 14:00:44 2013 UTC
+++ /src/robot/htmldata/jsonwriter.py Thu Sep 19 09:21:15 2013 UTC
@@ -73,20 +73,17 @@
class StringDumper(_Dumper):
_handled_types = basestring
- _replace =
{'\\': '\\\\', '"': '\\"', '\t': '\\t', '\n': '\\n', '\r': '\\r'}
+ _search_and_replace = [('\\', '\\\\'), ('"', '\\"'), ('\t', '\\t'),
+ ('\n', '\\n'), ('\r', '\\r')]
def dump(self, data, mapping):
- self._write('"%s"' % ''.join(self._encode_chars(data)))
+ self._write('"%s"' % self._encode(data))
- def _encode_chars(self, string):
- # Performance optimized code..
- replace = self._replace
- for char in string:
- if char in replace:
- yield replace[char]
- else:
- val = ord(char)
- yield char if 31 < val < 127 else '\\u%04x' % val
+ def _encode(self, string):
+ for search, replace in self._search_and_replace:
+ if search in string:
+ string = string.replace(search, replace)
+ return string.encode('UTF-8')
class IntegerDumper(_Dumper):
=======================================
--- /utest/htmldata/test_jsonwriter.py Thu Sep 19 09:06:33 2013 UTC
+++ /utest/htmldata/test_jsonwriter.py Thu Sep 19 09:21:15 2013 UTC
@@ -28,7 +28,7 @@
self._test('123', '"123"')
def test_dump_non_ascii_string(self):
- self._test(u'hyv\xe4', '"hyv\\u00e4"')
+ self._test(u'hyv\xe4', u'"hyv\xe4"'.encode('UTF-8'))
def test_escape_string(self):
self._test('"-\\-\n-\t-\r', '"\\"-\\\\-\\n-\\t-\\r"')
@@ -78,15 +78,14 @@
if json:
def test_against_standard_json(self):
- string = u'*string\u00A9\v\\\'\"\r\t\njee' \
- + u''.join(unichr(i) for i in xrange(32, 1024))
- data = [string, {'A': 1}, None]
- expected = StringIO()
+ data = ['\\\'\"\r\t\n' + ''.join(chr(i) for i in xrange(32,
127)),
+ {'A': 1, 'b': 2, 'C': ()}, None, (1, 2, 3)]
try:
- json.dump(data, expected, separators=(',', ':'))
+ expected = json.dumps(data, sort_keys=True,
+ separators=(',', ':'))
except UnicodeError:
return # http://ironpython.codeplex.com/workitem/32331
- self._test(data, expected.getvalue())
+ self._test(data, expected)
if __name__ == '__main__':
--
---
You received this message because you are subscribed to the Google Groups "robotframework-commit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to robotframework-commit+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.