[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/TextIndexNG/tests - testThesaurus.py:1.1.2.1

Andreas Jung andreas@digicool.com
Sun, 3 Feb 2002 14:19:55 -0500


Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TextIndexNG/tests
In directory cvs.zope.org:/tmp/cvs-serv3272/tests

Added Files:
      Tag: ajung-textindexng-branch
	testThesaurus.py 
Log Message:
added


=== Added File Zope/lib/python/Products/PluginIndexes/TextIndexNG/tests/testThesaurus.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# 
##############################################################################

import sys, os, unittest, tempfile

from Products.PluginIndexes.TextIndexNG.BaseThesaurus import BaseThesaurus 

_d = """
go walk,dance,hike
talk speak
"""

class Tests(unittest.TestCase):

    def setUp(self):
	
	self.fn = tempfile.mktemp()
	fp = open(self.fn,'w')
	fp.write(_d)
        fp.close()

        self._t= BaseThesaurus(self.fn)    


    def tearDown(self):
	os.unlink( self.fn )

    def testSimpleTest(self):
        """ a very basic thesaurus test """

	self.assertEqual( len(self._t) ,2) 

	assert 'go' in self._t.keys()
	assert 'talk' in self._t.keys()
	assert 'bla' not in self._t.keys()

       

def test_suite():
   return unittest.makeSuite(Tests)

def main():
   unittest.TextTestRunner().run(test_suite())

def debug():
   test_suite().debug()

def pdebug():
    import pdb
    pdb.run('debug()')
   
if __name__=='__main__':
   if len(sys.argv) > 1:
      globals()[sys.argv[1]]()
   else:
      main()