parserkeyword can create deckkeyword. python parserkeyword: removed create_deckkeyword. DeckKeyword: member parser_keyword is shared_ptr. python DeckKeyword constructor. python: no exposure of ParserKeyword. DeckKeyword: shared_ptr<ParserKeyword> -> ParskerKeyword. python/cxx/deck_keyword.cpp: cosntructor takes arg const ParskerKeyword&. test_parser.py: simplified test_pyinut. ...
68 lines
1.2 KiB
Python
68 lines
1.2 KiB
Python
import unittest
|
|
import os.path
|
|
import sys
|
|
|
|
from opm.io.parser import Parser
|
|
from opm.io.parser import ParseContext
|
|
|
|
from opm.io.deck import DeckKeyword
|
|
|
|
|
|
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)
|
|
|
|
def test_create_deck_kw(self):
|
|
parser = Parser()
|
|
with self.assertRaises(ValueError):
|
|
kw = parser["NOT_A_VALID_KEYWORD"]
|
|
|
|
kw = parser["FIELD"]
|
|
assert(kw.name == "FIELD")
|
|
|
|
dkw = DeckKeyword(kw)
|
|
assert(dkw.name == "FIELD")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|
|
|