[Zope-Checkins] CVS: Zope2 - sortx_test1.py:1.1.2.1 sortx_test2.py:1.1.2.1 sortx_test3.py:1.1.2.1 sortx_test4.py:1.1.2.1 sortx_test5.py:1.1.2.1 sortx_test6.py:1.1.2.1 sortx_test7.py:1.1.2.1 ztestlib.py:1.1.2.1

andreas@serenade.digicool.com andreas@serenade.digicool.com
Tue, 15 May 2001 17:00:45 -0400


Update of /cvs-repository/Zope2/lib/python/sequence/tests
In directory serenade:/tmp/cvs-serv17671/tests

Added Files:
      Tag: ajung-dtml-sort
	sortx_test1.py sortx_test2.py sortx_test3.py sortx_test4.py 
	sortx_test5.py sortx_test6.py sortx_test7.py ztestlib.py 
Log Message:
added tests



--- Added File sortx_test1.py in package Zope2 ---
#! /usr/local/bin/python


import sys
from ztestlib import *
from SortEx import SortEx

print SortEx(wordlist)

--- Added File sortx_test2.py in package Zope2 ---
#! /usr/local/bin/python


import sys
from ztestlib import *
from SortEx import SortEx

print SortEx(wordlist, (("key",),), mapping=1)

--- Added File sortx_test3.py in package Zope2 ---
#! /usr/local/bin/python


import sys
from ztestlib import *
from SortEx import SortEx

print SortEx(wordlist, (("key", "cmp"),), mapping=1)

--- Added File sortx_test4.py in package Zope2 ---
#! /usr/local/bin/python


import sys
from ztestlib import *
from SortEx import SortEx

print SortEx(wordlist, (("key", "cmp", "desc"),), mapping=1)

--- Added File sortx_test5.py in package Zope2 ---
#! /usr/local/bin/python


import sys
from ztestlib import *
from SortEx import SortEx

print SortEx(wordlist, (("weight",), ("key",)), mapping=1)

--- Added File sortx_test6.py in package Zope2 ---
#! /usr/local/bin/python


import sys
from ztestlib import *
from SortEx import SortEx

print SortEx(wordlist, (("weight",), ("key", "nocase", "desc")), mapping=1)

--- Added File sortx_test7.py in package Zope2 ---
#! /usr/local/bin/python


import sys
from ztestlib import *
from SortEx import SortEx


def myCmp(s1, s2):
   return -cmp(s1, s2)


# Create namespace...
from DocumentTemplate.DT_Util import TemplateDict
md = TemplateDict()

#... and push out function onto the namespace
md._push({"myCmp" : myCmp})


print SortEx(wordlist, (("weight",), ("key", "myCmp", "desc")), md, mapping=1)

--- Added File ztestlib.py in package Zope2 ---


class standard_html: # Base class for using with ZTemplates
   def __init__(self, title):
      self.standard_html_header = """<HTML>
   <HEAD>
      <TITLE>
         %s
      </TITLE>
   </HEAD>

<BODY>""" % title

      self.standard_html_footer = """</BODY>
</HTML>"""

      self.title = title


def test(s):
   outfile = open("test.out", 'w')
   outfile.write(s)
   outfile.close()


def exception():
   import sys, traceback
   exc_type, exc_value, exc_tb = sys.exc_info()

   outfile = open("test.err", 'w')
   traceback.print_exception(exc_type, exc_value, exc_tb, None, outfile)
   outfile.close()


wordlist = [
   {"key": "aaa", "word": "AAA", "weight": 1},
   {"key": "bbb", "word": "BBB", "weight": 0},
   {"key": "ccc", "word": "CCC", "weight": 0},
   {"key": "ddd", "word": "DDD", "weight": 0},
   {"key": "eee", "word": "EEE", "weight": 1},
   {"key": "fff", "word": "FFF", "weight": 0},
   {"key": "ggg", "word": "GGG", "weight": 0},
   {"key": "hhh", "word": "HHH", "weight": 0},
   {"key": "iii", "word": "III", "weight": 1},
   {"key": "jjj", "word": "JJJ", "weight": -1},
   {"key": "kkk", "word": "KKK", "weight": 0},
   {"key": "lll", "word": "LLL", "weight": 0},
   {"key": "mmm", "word": "MMM", "weight": 0},
   {"key": "nnn", "word": "NNN", "weight": 0},
   {"key": "ooo", "word": "OOO", "weight": 1},
   {"key": "ppp", "word": "PPP", "weight": 0},
   {"key": "qqq", "word": "QQQ", "weight": -1},
   {"key": "rrr", "word": "RRR", "weight": 0},
   {"key": "sss", "word": "SSS", "weight": 0},
   {"key": "ttt", "word": "TTT", "weight": 0},
   {"key": "uuu", "word": "UUU", "weight": 1},
   {"key": "vvv", "word": "VVV", "weight": 0},
   {"key": "www", "word": "WWW", "weight": 0},
   {"key": "xxx", "word": "XXX", "weight": 0},
   {"key": "yyy", "word": "YYY", "weight": -1},
   {"key": "zzz", "word": "ZZZ", "weight": 0}
]