Expose the Parser class properly to Python

This commit is contained in:
Joakim Hove
2019-09-04 14:42:52 +02:00
parent 1d8f07fe62
commit 7984d2a0f4
9 changed files with 103 additions and 16 deletions

View File

@@ -0,0 +1,52 @@
import unittest
import os.path
import sys
from opm.io.parser import Parser
from opm.io.parser import ParseContext
class TestParser(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_create(self):
parser = Parser()
deck = parser.parse(self.spe3fn)
context = ParseContext()
deck = parser.parse(self.spe3fn, context)
with open(self.spe3fn) as f:
string = f.read()
deck = parser.parse_string(string)
deck = parser.parse_string(string, context)
if __name__ == "__main__":
unittest.main()