[Zope-Checkins] CVS: Zope3/lib/python/Zope/PageTemplate/tests - framework.py:1.1.2.4 util.py:1.1.2.5
Martijn Pieters
mj@zope.com
Wed, 13 Feb 2002 00:03:38 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/PageTemplate/tests
In directory cvs.zope.org:/tmp/cvs-serv14206/PageTemplate/tests
Modified Files:
Tag: Zope-3x-branch
framework.py util.py
Log Message:
Optimizations and code style updates:
- Use isinstance on type checks
- Test UnicodeType and StringType through StringTypes
- Remove use of the string module
- Use startswith and endswith instead of slices.
- Fix weird tests where isinstance suffices.
=== Zope3/lib/python/Zope/PageTemplate/tests/framework.py 1.1.2.3 => 1.1.2.4 ===
# FOR A PARTICULAR PURPOSE.
-import string
-
scriptdir = sys.path[0]
input_dir = os.path.join(scriptdir, 'input')
output_dir = os.path.join(scriptdir, 'output')
=== Zope3/lib/python/Zope/PageTemplate/tests/util.py 1.1.2.4 => 1.1.2.5 ===
# FOR A PARTICULAR PURPOSE.
-import os, sys, string, re
+import os, sys, re
+from types import IntType
class Bruce:
__allow_access_to_unprotected_subobjects__=1
@@ -17,12 +18,12 @@
def items(self): return [('bruce',self)]*7
def __len__(self): return 7
def __getitem__(self,index):
- if (type(index) is type(1) and
+ if (ininstance(index, IntType) and
(index < 0 or index > 6)): raise IndexError, index
return self
isDocTemp=0
def __getattr__(self,name):
- if name[:1]=='_': raise AttributeError, name
+ if name.startswith('_'): raise AttributeError, name
return self
bruce=Bruce()
@@ -62,8 +63,8 @@
if s1!=s2:
print
from OFS.ndiff import SequenceMatcher, dump, IS_LINE_JUNK
- a = string.split(s1, '\n')
- b = string.split(s2, '\n')
+ a = s1.split('\n')
+ b = s2.split('\n')
def add_nl(s):
return s + '\n'
a = map(add_nl, a)