Files
opm-common/python/tests/test_parse.py
Steinar Foss c208a59597 Sunbeam will be compiled with setuptools.
setup.py moved to python/python.

moved python tests to python/python.

added __init__.py under python/tests.

added 'test_' before all python test names.

test_ prefix added to tests.

setup.py and python tests moved back to python base.

setuptools executes from root python.

python: tests run from root python w/ setup.py.

python tests: temp reduced to test_deck only.

python setup.py: manually linked opmcommon.

setup.py: linked ecl.

setup.py linked boost_filesystem.

setup.py: linked boost_regex.

python all tests run.

removec usr/local from setup.py ext_module.

cmake make copies entire python dir to build.

setup.py can execute from build.

setup.py executes from build/python.

python tests run under setup.py.

setup.py library_dirs and include-dirs set by cmake command.

removed cmake files from sunbeam.

sunbeam: added code for install.

setup.py: removed 'import ecl'.

python/src -> python->src_sunbeam.

setup.py: discontinued use of glob, all files listed instead.

build-opm_module.sh: added prefix_path to opm.

build-opm-module.sh: changed spell error for EXTRA_MODULE_FLAGS[opm-common].

setup.py: infer include directories from cmake target

CMakeLists.txt: under python: align install statement.

CMakeLists build python: removed find_package.

src_sunbeam -> cxx.

setup.py: test_suite as string.

setup.py: tests_suite -> test_suite.

setup.py: added exception if 'build_ext' not used.

temporarily moved files to python/sunbeam.
2019-08-09 10:40:33 +02:00

75 lines
1.8 KiB
Python

import unittest
import sunbeam
import os.path
import sys
class TestParse(unittest.TestCase):
REGIONDATA = """
START -- 0
10 MAI 2007 /
RUNSPEC
DIMENS
2 2 1 /
GRID
DX
4*0.25 /
DY
4*0.25 /
DZ
4*0.25 /
TOPS
4*0.25 /
REGIONS
OPERNUM
3 3 1 2 /
FIPNUM
1 1 2 3 /
"""
def setUp(self):
self.spe3fn = 'tests/spe3/SPE3CASE1.DATA'
self.norne_fname = os.path.abspath('examples/data/norne/NORNE_ATW2013.DATA')
def test_parse(self):
spe3 = sunbeam.parse(self.spe3fn)
self.assertEqual('SPE 3 - CASE 1', spe3.state.title)
def test_parse_with_recovery(self):
recovery = [("PARSE_RANDOM_SLASH", sunbeam.action.ignore)]
spe3 = sunbeam.parse(self.spe3fn, recovery=recovery)
def test_parse_with_multiple_recoveries(self):
recoveries = [ ("PARSE_RANDOM_SLASH", sunbeam.action.ignore),
("FOO", sunbeam.action.warn),
("PARSE_RANDOM_TEXT", sunbeam.action.throw) ]
spe3 = sunbeam.parse(self.spe3fn, recovery=recoveries)
def test_throw_on_invalid_recovery(self):
recoveries = [ ("PARSE_RANDOM_SLASH", 3.14 ) ]
with self.assertRaises(TypeError):
sunbeam.parse(self.spe3fn, recovery=recoveries)
with self.assertRaises(TypeError):
sunbeam.parse(self.spe3fn, recovery="PARSE_RANDOM_SLASH")
def test_data(self):
pass
#regtest = sunbeam.parse(self.REGIONDATA)
#self.assertEqual([3,3,1,2], regtest.props()['OPERNUM'])
def test_parse_norne(self):
state = sunbeam.parse(self.norne_fname, recovery=[('PARSE_RANDOM_SLASH', sunbeam.action.ignore)])
es = state.state
self.assertEqual(46, es.grid().getNX())
self.assertEqual(112, es.grid().getNY())
self.assertEqual(22, es.grid().getNZ())
if __name__ == "__main__":
unittest.main()