Beispiel #1
0
import time
import strutil
import cgi
import os
import test
import codecs

text = unicode(open('xanadu.txt').read())

print 'xanadu'
print '------'

t = time.time()
strutil.escape(text)
print 'fast = %s' % (time.time() - t)

t = time.time()
test.slow_escape(text)
print 'slow = %s' % (time.time() - t)

text = unicode(open('yelp.txt').read())

# make the unicode string object really big so lots of replacements will happen
for x in range(7):
	text += text

print
print 'yelp html'
print '------------'

t = time.time()
Beispiel #2
0
	def test_uni_khmer_characters(self):
		for s in ('សា'):
			assert strutil.escape(s) == slow_escape(s)
Beispiel #3
0
	def test_uni_needs_escaping(self):
		for s in (u'', u'&', u'\\', u'"', u'foo&bar', u'foo&bar"baz\\'):
			assert strutil.escape(s) == slow_escape(s)
Beispiel #4
0
	def test_regular_uni(self):
		# unescaped unicodes shouldn't return a new reference
		for s in (u'', u'a', u'foo', u'foobarbaz'):
			escaped = strutil.escape(s)
			assert escaped is s
			assert slow_escape(s) == escaped
Beispiel #5
0
	def test_str_needs_escaping(self):
		for s in ('', '&', '\\', '"', 'foo&bar', 'foo&bar"baz\\'):
			assert strutil.escape(s) == slow_escape(s)
Beispiel #6
0
	def test_regular_str(self):
		# unescaped strings shouldn't return a new reference
		for s in ('', 'a', 'foo', 'foobarbaz'):
			escaped = strutil.escape(s)
			assert escaped is s
			assert slow_escape(s) == escaped