Contact: fumanchu@aminus.org

Log in as guest/dejavu to create tickets

I think I've seen this ORM somewhere before...

root/tags/1.4.0/test/test.py

Revision 100 (checked in by fumanchu, 7 years ago)

More test suite work. If a store is not installed or cannot be imported, a warning will be raised and the tests will not be run.

  • Property svn:eol-style set to native
Line 
1 import getopt
2 import sys
3 import unittest
4
5 from dejavu.test import tools
6
7
8 class djvTestHarness(object):
9     """A test harness for Dejavu."""
10    
11     def __init__(self, available_tests):
12         """Constructor to populate the TestHarness instance.
13         
14         available_tests should be a list of module names (strings).
15         """
16         self.available_tests = available_tests
17         self.tests = []
18    
19     def load(self, args=sys.argv[1:]):
20         """Populate a TestHarness from sys.argv.
21         
22         args defaults to sys.argv[1:], but you can provide a different
23             set of args if you like.
24         """
25        
26         longopts = ['help']
27         longopts.extend(self.available_tests)
28         try:
29             opts, args = getopt.getopt(args, "", longopts)
30         except getopt.GetoptError:
31             # print help information and exit
32             self.help()
33             sys.exit(2)
34        
35         self.tests = []
36        
37         for o, a in opts:
38             if o == '--help':
39                 self.help()
40                 sys.exit()
41             else:
42                 o = o[2:]
43                 if o in self.available_tests and o not in self.tests:
44                     self.tests.append(o)
45        
46         if not self.tests:
47             self.tests = self.available_tests[:]
48    
49     def help(self):
50         """Print help for test.py command-line options."""
51        
52         print """
53 Dejavu Test Program
54     Usage:
55         test.py --<testname>
56         
57         tests:"""
58         for name in self.available_tests:
59             print '        --' + name
60    
61     def run(self, conf=None):
62         """Run the test harness."""
63         self.load()
64        
65         import dejavu
66         print "Python version:", sys.version.split()[0]
67         print "Dejavu version:", dejavu.__version__
68        
69         for testmod in self.tests:
70             if testmod.startswith("test_store"):
71                 print
72                 print "Testing %s storage..." % testmod[10:]
73                 mod = __import__(testmod, globals(), locals(), [''])
74                 mod.run()
75             else:
76                 suite = unittest.TestLoader().loadTestsFromName(testmod)
77                 tools.djvTestRunner.run(suite)
78
79
80 def run():
81    
82     tools.prefer_parent_path()
83    
84     testList = [
85         'test_analysis',
86         'test_codewalk',
87         'test_containers',
88         'test_dejavu',
89         'test_logic',
90         'test_storeburned',
91         'test_storecaching',
92         'test_storemsaccess',
93         'test_storemysql',
94 ##        'test_storeodbc',
95         'test_storeproxy',
96         'test_storepypgsql',
97         'test_storeshelve',
98         'test_storesqlite',
99         'test_storesqlserver',
100     ]
101     djvTestHarness(testList).run()
102
103
104 if __name__ == '__main__':
105     run()
Note: See TracBrowser for help on using the browser.