summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/DocutilsTestSupport.py2
-rw-r--r--test/docutils_difflib.py15
-rwxr-xr-xtest/test_dependencies.py2
-rwxr-xr-xtest/test_functional.py6
-rwxr-xr-xtest/test_language.py8
-rwxr-xr-xtest/test_nodes.py2
-rwxr-xr-xtest/test_settings.py4
7 files changed, 21 insertions, 18 deletions
diff --git a/test/DocutilsTestSupport.py b/test/DocutilsTestSupport.py
index ce67ab262..24858c624 100644
--- a/test/DocutilsTestSupport.py
+++ b/test/DocutilsTestSupport.py
@@ -668,7 +668,7 @@ class WriterPublishTestCase(CustomTestCase, docutils.SettingsSpec):
writer_name = '' # set in subclasses or constructor
def __init__(self, *args, **kwargs):
- if 'writer_name' in kwargs:
+ if kwargs.has_key('writer_name'):
self.writer_name = kwargs['writer_name']
del kwargs['writer_name']
CustomTestCase.__init__(self, *args, **kwargs)
diff --git a/test/docutils_difflib.py b/test/docutils_difflib.py
index 1865c2117..a41d4d5ba 100644
--- a/test/docutils_difflib.py
+++ b/test/docutils_difflib.py
@@ -163,6 +163,8 @@ class SequenceMatcher:
# b2j
# for x in b, b2j[x] is a list of the indices (into b)
# at which x appears; junk elements do not appear
+ # b2jhas
+ # b2j.has_key
# fullbcount
# for x in b, fullbcount[x] == the number of times x
# appears in b; only materialized if really needed (used
@@ -186,7 +188,7 @@ class SequenceMatcher:
# DON'T USE! Only __chain_b uses this. Use isbjunk.
# isbjunk
# for x in b, isbjunk(x) == isjunk(x) but much faster;
- # it's really the in operator of a hidden dict.
+ # it's really the has_key method of a hidden dict.
# DOES NOT WORK for x in a!
self.isjunk = isjunk
@@ -283,9 +285,10 @@ class SequenceMatcher:
# from the start.
b = self.b
self.b2j = b2j = {}
+ self.b2jhas = b2jhas = b2j.has_key
for i in xrange(len(b)):
elt = b[i]
- if elt in b2j:
+ if b2jhas(elt):
b2j[elt].append(i)
else:
b2j[elt] = [i]
@@ -301,12 +304,12 @@ class SequenceMatcher:
junkdict[elt] = 1 # value irrelevant; it's a set
del b2j[elt]
- # Now for x in b, isjunk(x) == x in junkdict, but the
+ # Now for x in b, isjunk(x) == junkdict.has_key(x), but the
# latter is much faster. Note too that while there may be a
# lot of junk in the sequence, the number of *unique* junk
# elements is probably small. So the memory burden of keeping
# this dict alive is likely trivial compared to the size of b2j.
- self.isbjunk = lambda elt: elt in junkdict
+ self.isbjunk = junkdict.has_key
def find_longest_match(self, alo, ahi, blo, bhi):
"""Find longest matching block in a[alo:ahi] and b[blo:bhi].
@@ -547,9 +550,9 @@ class SequenceMatcher:
# avail[x] is the number of times x appears in 'b' less the
# number of times we've seen it in 'a' so far ... kinda
avail = {}
- matches = 0
+ availhas, matches = avail.has_key, 0
for elt in self.a:
- if elt in avail:
+ if availhas(elt):
numb = avail[elt]
else:
numb = fullbcount.get(elt, 0)
diff --git a/test/test_dependencies.py b/test/test_dependencies.py
index c9463b440..d82f52c55 100755
--- a/test/test_dependencies.py
+++ b/test/test_dependencies.py
@@ -28,7 +28,7 @@ class RecordDependenciesTests(unittest.TestCase):
settings.setdefault('settings_overrides', {})
settings['settings_overrides'] = settings['settings_overrides'].copy()
settings['settings_overrides']['_disable_config'] = 1
- if 'record_dependencies' not in settings['settings_overrides']:
+ if not settings['settings_overrides'].has_key('record_dependencies'):
settings['settings_overrides']['record_dependencies'] = \
docutils.utils.DependencyList(recordfile)
docutils.core.publish_file(destination=DocutilsTestSupport.DevNull(),
diff --git a/test/test_functional.py b/test/test_functional.py
index 9d129f412..26f4533c6 100755
--- a/test/test_functional.py
+++ b/test/test_functional.py
@@ -95,9 +95,9 @@ class FunctionalTestCase(DocutilsTestSupport.CustomTestCase):
execfile(join_path(datadir, 'tests', '_default.py'), namespace)
execfile(self.configfile, namespace)
# Check for required settings:
- assert 'test_source' in namespace,\
+ assert namespace.has_key('test_source'),\
"No 'test_source' supplied in " + self.configfile
- assert 'test_destination' in namespace,\
+ assert namespace.has_key('test_destination'),\
"No 'test_destination' supplied in " + self.configfile
# Set source_path and destination_path if not given:
namespace.setdefault('source_path',
@@ -151,7 +151,7 @@ class FunctionalTestCase(DocutilsTestSupport.CustomTestCase):
print >>sys.stderr, diff
raise
# Execute optional function containing extra tests:
- if '_test_more' in namespace:
+ if namespace.has_key('_test_more'):
namespace['_test_more'](join_path(datadir, 'expected'),
join_path(datadir, 'output'),
self, namespace)
diff --git a/test/test_language.py b/test/test_language.py
index 6fd0ee546..3f929bd05 100755
--- a/test/test_language.py
+++ b/test/test_language.py
@@ -76,10 +76,10 @@ class LanguageTestCase(DocutilsTestSupport.CustomTestCase):
missing = [] # in ref but not in l.
too_much = [] # in l but not in ref.
for label in ref_dict.keys():
- if label not in l_dict:
+ if not l_dict.has_key(label):
missing.append(label)
for label in l_dict.keys():
- if label not in ref_dict:
+ if not ref_dict.has_key(label):
too_much.append(label)
return (missing, too_much)
@@ -140,7 +140,7 @@ class LanguageTestCase(DocutilsTestSupport.CustomTestCase):
canonical.sort()
canonical.remove('restructuredtext-test-directive')
for name in canonical:
- if name not in inverted:
+ if not inverted.has_key(name):
failures.append('"%s": translation missing' % name)
if failures:
text = ('Module docutils.parsers.rst.languages.%s:\n %s'
@@ -175,7 +175,7 @@ class LanguageTestCase(DocutilsTestSupport.CustomTestCase):
canonical.sort()
canonical.remove('restructuredtext-unimplemented-role')
for name in canonical:
- if name not in inverted:
+ if not inverted.has_key(name):
failures.append('"%s": translation missing' % name)
if failures:
text = ('Module docutils.parsers.rst.languages.%s:\n %s'
diff --git a/test/test_nodes.py b/test/test_nodes.py
index 2da605aea..c981a4e96 100755
--- a/test/test_nodes.py
+++ b/test/test_nodes.py
@@ -91,7 +91,7 @@ class ElementTests(unittest.TestCase):
def test_normal_attributes(self):
element = nodes.Element()
- self.assert_('foo' not in element)
+ self.assert_(not element.has_key('foo'))
self.assertRaises(KeyError, element.__getitem__, 'foo')
element['foo'] = 'sometext'
self.assertEquals(element['foo'], 'sometext')
diff --git a/test/test_settings.py b/test/test_settings.py
index fb050b2ad..2cf4e080c 100755
--- a/test/test_settings.py
+++ b/test/test_settings.py
@@ -92,8 +92,8 @@ class ConfigFileTests(unittest.TestCase):
def compare_output(self, result, expected):
"""`result` and `expected` should both be dicts."""
- self.assert_('record_dependencies' in result)
- if 'record_dependencies' not in expected:
+ self.assert_(result.has_key('record_dependencies'))
+ if not expected.has_key('record_dependencies'):
# Delete it if we don't want to test it.
del result['record_dependencies']
result = pprint.pformat(result) + '\n'