""" Test suite for the sodar package. """ __author__ = 'Chris Calloway' __email__ = 'cbc@chriscalloway.org' __copyright__ = 'Copyright 2009 UNC-CH Department of Marine Science' __license__ = 'GPL2' import os import unittest import doctest def setUpData(data_dir,data_file): """ Get data from test file. setUpData(data_dir,data_file) -> (data_path, data) Where: data_dir is a str representation of a relative path in tests/data, data_file is a str representation of a data file within data_dir, data_path is a str representation of the absolute path to data_file, data is a str representation of the contents of data_file. """ module_dir = os.path.abspath(os.path.dirname(__file__)) data_path = os.path.join(module_dir,'data',data_dir,data_file) data = open(data_path).read() return (data_path, data) def setUpGoodMndData(): """ Get data from a known good Scintec .mnd file. """ mnd_dir = os.path.join('scintec','good',) mnd_file = '091117.mnd' return setUpData(mnd_dir,mnd_file) def setUpGoodMnd(test): """ Test set up for a good Scintec .mnd file. """ mnd_path,mnd = setUpGoodMndData() mnd_path,mnd_file = os.path.split(mnd_path) test.globs.update(good_mnd=mnd, good_name=mnd_file, good_path=mnd_path) def test_suite(): """ Return unittest.TestSuite for setup.py test. """ suite = [] suite.append(doctest.DocTestSuite(module='sodar.scintec.maindata', setUp=setUpGoodMnd)) return unittest.TestSuite(suite)