removed all test suppoert for parser_module.py.

This commit is contained in:
Steinar Foss
2019-10-10 11:56:59 +02:00
parent 3cc205ee93
commit 0e1339e648
4 changed files with 15 additions and 13 deletions

View File

@@ -5,8 +5,7 @@ try:
except ImportError:
from io import StringIO
from opm.io.parser import load_deck, load_deck_string
from opm.io.parser import Parser
# This is from the TimeMap.cpp implementation in opm
ecl_month = {"JAN" : 1,
@@ -213,11 +212,11 @@ class TimeVector(object):
self._add_dates_block(ts)
start_dt = datetime.datetime(start_date.year, start_date.month, start_date.day)
if base_file:
deck = load_deck(base_file)
deck = Parser().parse(base_file)
self._add_deck(deck, start_dt)
if base_string:
deck = load_deck_string(base_string)
deck = Parser().parse_string(base_string)
self._add_deck(deck, start_dt)
@@ -328,7 +327,7 @@ class TimeVector(object):
tv.load("well.sch", date = datetime.datetime(2017, 4, 1))
"""
deck = load_deck(filename)
deck = Parser().parse(filename)
self._add_deck(deck, date)
@@ -336,7 +335,7 @@ class TimeVector(object):
"""
Like load() - but load from a string literal instead of file.
"""
deck = load_deck_string(deck_string)
deck = Parser().parse_string(deck_string)
self._add_deck(deck, date)

View File

@@ -1,5 +1,6 @@
import unittest
from opm.io import load_deck_string
from opm.io.parser import Parser
class TestParse(unittest.TestCase):
@@ -27,7 +28,7 @@ FIPNUM
"""
def setUp(self):
self.deck = load_deck_string(self.DECK_STRING)
self.deck = Parser().parse_string(self.DECK_STRING)
def test_deck_in(self):
map(lambda kw: self.assertIn(kw, self.deck), [
@@ -49,7 +50,7 @@ FIPNUM
str(self.deck['DX']).split()
)
self.assertEqual(
str(load_deck_string('RUNSPEC\n\nDX\n4*0.5 /')).split(),
str( Parser().parse_string('RUNSPEC\n\nDX\n4*0.5 /') ).split(),
'RUNSPEC DX 0.5 0.5 0.5 0.5 /'.split()
)

View File

@@ -57,8 +57,8 @@ FIPNUM
self.norne_fname = os.path.abspath('../../examples/data/norne/NORNE_ATW2013.DATA')
def test_IOError(self):
with self.assertRaises(IOError):
opm.io.load_deck("file/not/found")
with self.assertRaises(Exception):
Parser().parse("file/not/found")
def test_parser_fail_without_extension(self):

View File

@@ -1,7 +1,9 @@
import unittest
import datetime
from opm.tools import *
from opm.io import load_deck_string, load_deck
from opm.io.parser import Parser
from utils import tmp
class TestTimeVector(unittest.TestCase):
@@ -119,7 +121,7 @@ class TestTimeVector(unittest.TestCase):
def test_no_leading_DATES(self):
tv = TimeVector(datetime.date(1997, 11, 6), base_file="tests/data/schedule/part1.sch")
s = str(tv)
d = load_deck_string(s)
d = Parser().parse_string(s)
kw0 = d[0]
self.assertEqual(kw0.name, "WELSPECS")