Commits

Matt Chaput committed 7478e42

Added if __name__ test to setup.py to prevent inf. test recursion on Windows.
Switched py.test configuration to use native tracebacks.
Moved simple double-metaphone tests from module __main__ into a unit test.

  • Participants
  • Parent commits 29efbbe

Comments (0)

Files changed (4)

 pushdocs = build_sphinx upload_sphinx
 
 [pytest]
-addopts = --pep8 -rs
+; --tb= traceback print mode (long/short/line/native/no)
+addopts = --pep8 -rs --tb=native
+
 norecursedirs = .hg .tox _build tmp* env* benchmark stress
 minversion = 2.0
+python_files = test_*.py
 pep8ignore =
  *.py E121 E122 E123 E124 E125 E126 E127 E128  # continuation line indentation
  *.py E401  # imports on separate lines
 sys.path.insert(0, os.path.abspath("src"))
 from whoosh import __version__, versionstring
 
-setup(
-    name="Whoosh",
-    version=versionstring(),
-    package_dir={'': 'src'},
-    packages=find_packages(),
+if __name__ == "__main__":
+    setup(
+        name="Whoosh",
+        version=versionstring(),
+        package_dir={'': 'src'},
+        packages=find_packages(),
 
-    author="Matt Chaput",
-    author_email="matt@whoosh.ca",
+        author="Matt Chaput",
+        author_email="matt@whoosh.ca",
 
-    description="Fast, pure-Python full text indexing, search, and spell checking library.",
-    long_description=open("README.txt").read(),
+        description="Fast, pure-Python full text indexing, search, and spell checking library.",
+        long_description=open("README.txt").read(),
 
-    license="Two-clause BSD license",
-    keywords="index search text spell",
-    url="http://bitbucket.org/mchaput/whoosh",
+        license="Two-clause BSD license",
+        keywords="index search text spell",
+        url="http://bitbucket.org/mchaput/whoosh",
 
-    zip_safe=True,
-    test_suite="nose.collector",
+        zip_safe=True,
+        test_suite="nose.collector",
 
-    classifiers=[
-    "Development Status :: 5 - Production/Stable",
-    "Intended Audience :: Developers",
-    "License :: OSI Approved :: BSD License",
-    "Natural Language :: English",
-    "Operating System :: OS Independent",
-    "Programming Language :: Python :: 2.5",
-    "Programming Language :: Python :: 3",
-    "Topic :: Software Development :: Libraries :: Python Modules",
-    "Topic :: Text Processing :: Indexing",
-    ],
-)
+        classifiers=[
+        "Development Status :: 5 - Production/Stable",
+        "Intended Audience :: Developers",
+        "License :: OSI Approved :: BSD License",
+        "Natural Language :: English",
+        "Operating System :: OS Independent",
+        "Programming Language :: Python :: 2.5",
+        "Programming Language :: Python :: 3",
+        "Topic :: Software Development :: Libraries :: Python Modules",
+        "Topic :: Text Processing :: Indexing",
+        ],
+    )

File src/whoosh/lang/dmetaphone.py

     else:
         return (primary, secondary)
 
-if __name__ == '__main__':
-    names = {'maurice': ('MRS', None), 'aubrey': ('APR', None), 'cambrillo': ('KMPRL', 'KMPR'),
-        'heidi': ('HT', None), 'katherine': ('K0RN', 'KTRN'), 'Thumbail': ('0MPL', 'TMPL'),
-        'catherine': ('K0RN', 'KTRN'), 'richard': ('RXRT', 'RKRT'), 'bob': ('PP', None), \
-        'eric': ('ARK', None), 'geoff': ('JF', 'KF'), 'Through': ('0R', 'TR'), 'Schwein': ('XN', 'XFN'),
-        'dave': ('TF', None), 'ray': ('R', None), 'steven': ('STFN', None), 'bryce': ('PRS', None),
-        'randy': ('RNT', None), 'bryan': ('PRN', None), 'Rapelje': ('RPL', None),
-        'brian': ('PRN', None), 'otto': ('AT', None), 'auto': ('AT', None), 'Dallas': ('TLS', None),
-        'maisey': ('MS', None), 'zhang': ('JNK', None), 'Chile': ('XL', None),
-        'Jose': ('HS', None), 'Arnow': ('ARN', 'ARNF'), 'solilijs': ('SLLS', None),
-        'Parachute': ('PRKT', None), 'Nowhere': ('NR', None), 'Tux': ('TKS', None)}
-    for name in names.keys():
-        assert (double_metaphone(name) == names[name]), 'For "%s" function returned %s. Should be %s.' % (name, double_metaphone(name), names[name])

File tests/test_analysis.py

 
 
 def test_double_metaphone():
+    from whoosh.lang.dmetaphone import double_metaphone
+
+    names = {'maurice': ('MRS', None),
+             'aubrey': ('APR', None),
+             'cambrillo': ('KMPRL', 'KMPR'),
+             'heidi': ('HT', None),
+             'katherine': ('K0RN', 'KTRN'),
+             'Thumbail': ('0MPL', 'TMPL'),
+             'catherine': ('K0RN', 'KTRN'),
+             'richard': ('RXRT', 'RKRT'),
+             'bob': ('PP', None),
+             'eric': ('ARK', None),
+             'geoff': ('JF', 'KF'),
+             'Through': ('0R', 'TR'),
+             'Schwein': ('XN', 'XFN'),
+             'dave': ('TF', None),
+             'ray': ('R', None),
+             'steven': ('STFN', None),
+             'bryce': ('PRS', None),
+             'randy': ('RNT', None),
+             'bryan': ('PRN', None),
+             'Rapelje': ('RPL', None),
+             'brian': ('PRN', None),
+             'otto': ('AT', None),
+             'auto': ('AT', None),
+             'Dallas': ('TLS', None),
+             'maisey': ('MS', None),
+             'zhang': ('JNK', None),
+             'Chile': ('XL', None),
+             'Jose': ('HS', None),
+             'Arnow': ('ARN', 'ARNF'),
+             'solilijs': ('SLLS', None),
+             'Parachute': ('PRKT', None),
+             'Nowhere': ('NR', None),
+             'Tux': ('TKS', None)}
+    for name in names.keys():
+        dmn = double_metaphone(name)
+    assert_equal(dmn, names[name])
+
     mf = (analysis.RegexTokenizer()
           | analysis.LowercaseFilter()
           | analysis.DoubleMetaphoneFilter())
 def test_pickleability():
     ana = analysis.LanguageAnalyzer("en")
     pick = dumps(ana, -1)
+
+