Revision 254
(checked in by cbc, 15 years ago)
|
Added suite.py to last commit for setup.py test capability.
|
Line | |
---|
1 |
""" |
---|
2 |
Test suite for the sodar package. |
---|
3 |
""" |
---|
4 |
|
---|
5 |
__author__ = 'Chris Calloway' |
---|
6 |
__email__ = 'cbc@chriscalloway.org' |
---|
7 |
__copyright__ = 'Copyright 2009 UNC-CH Department of Marine Science' |
---|
8 |
__license__ = 'GPL2' |
---|
9 |
|
---|
10 |
import os |
---|
11 |
import unittest |
---|
12 |
import doctest |
---|
13 |
|
---|
14 |
def setUpData(data_dir,data_file): |
---|
15 |
""" |
---|
16 |
Get data from test file. |
---|
17 |
|
---|
18 |
setUpData(data_dir,data_file) -> str |
---|
19 |
|
---|
20 |
Where data_dir is a str representation of a relative path in test/data, and |
---|
21 |
data_file is a str representation of a data file within data_dir |
---|
22 |
""" |
---|
23 |
|
---|
24 |
module_dir = os.path.abspath(os.path.dirname(__file__)) |
---|
25 |
data_file = os.path.join(module_dir,'data',data_dir,data_file) |
---|
26 |
data = open(data_file).read() |
---|
27 |
return data |
---|
28 |
|
---|
29 |
def setUpGoodMndData(): |
---|
30 |
""" |
---|
31 |
Get data from a known good Scintec .mnd file. |
---|
32 |
""" |
---|
33 |
|
---|
34 |
return setUpData(os.path.join('scintec','good',),'091117.mnd') |
---|
35 |
|
---|
36 |
def setUpGoodMnd(test): |
---|
37 |
""" |
---|
38 |
Test set up for a good Scintec .mnd file. |
---|
39 |
""" |
---|
40 |
|
---|
41 |
mnd = setUpGoodMndData() |
---|
42 |
test.globs.update(good_mnd=mnd) |
---|
43 |
|
---|
44 |
def test_suite(): |
---|
45 |
""" |
---|
46 |
Return unittest.TestSuite for setup.py test. |
---|
47 |
""" |
---|
48 |
|
---|
49 |
suite = [] |
---|
50 |
suite.append(doctest.DocTestSuite(module='sodar.scintec.maindata', |
---|
51 |
setUp=setUpGoodMnd)) |
---|
52 |
return unittest.TestSuite(suite) |
---|