Use try: except: to import test utility code

This commit is contained in:
Joakim Hove
2019-10-28 20:16:13 +01:00
parent d382c57145
commit 99e32edd78
8 changed files with 37 additions and 12 deletions

View File

@@ -3,7 +3,10 @@ import unittest
from opm.io.parser import Parser from opm.io.parser import Parser
from opm.io.ecl_state import EclipseState from opm.io.ecl_state import EclipseState
from opm.io.schedule import Schedule from opm.io.schedule import Schedule
from utils import test_path try:
from tests.utils import test_path
except ImportError:
from utils import test_path
def flowing(connection): def flowing(connection):
return connection.state == 'OPEN' return connection.state == 'OPEN'

View File

@@ -5,7 +5,10 @@ import sys
from opm.io.parser import Parser, ParseContext from opm.io.parser import Parser, ParseContext
from opm.io.ecl_state import EclipseState from opm.io.ecl_state import EclipseState
from utils import test_path try:
from tests.utils import test_path
except ImportError:
from utils import test_path
class TestParse(unittest.TestCase): class TestParse(unittest.TestCase):

View File

@@ -7,7 +7,11 @@ import numpy as np
from opm.io.parser import Parser from opm.io.parser import Parser
from opm.io.parser import ParseContext from opm.io.parser import ParseContext
from opm.io.deck import DeckKeyword from opm.io.deck import DeckKeyword
from utils import test_path try:
from tests.utils import test_path
except ImportError:
from utils import test_path
unit_foot = 0.3048 #meters unit_foot = 0.3048 #meters

View File

@@ -3,7 +3,10 @@ import opm.io
from opm.io.parser import Parser from opm.io.parser import Parser
from opm.io.ecl_state import EclipseState from opm.io.ecl_state import EclipseState
from utils import test_path try:
from tests.utils import test_path
except ImportError:
from utils import test_path
class TestProps(unittest.TestCase): class TestProps(unittest.TestCase):

View File

@@ -4,8 +4,11 @@ import datetime as dt
from opm.io.parser import Parser from opm.io.parser import Parser
from opm.io.ecl_state import EclipseState from opm.io.ecl_state import EclipseState
from opm.io.schedule import Schedule from opm.io.schedule import Schedule
from utils import test_path
try:
from tests.utils import test_path
except ImportError:
from utils import test_path
class TestSchedule(unittest.TestCase): class TestSchedule(unittest.TestCase):

View File

@@ -5,8 +5,10 @@ from opm.io.parser import Parser
from opm.io.ecl_state import EclipseState from opm.io.ecl_state import EclipseState
from opm.io.schedule import Schedule from opm.io.schedule import Schedule
from opm.io.summary import SummaryConfig from opm.io.summary import SummaryConfig
from utils import test_path try:
from tests.utils import test_path
except ImportError:
from utils import test_path
class TestState2(unittest.TestCase): class TestState2(unittest.TestCase):
@@ -140,7 +142,7 @@ SATNUM
# jf["GAS_OIL"] = -1.0 # N/A # jf["GAS_OIL"] = -1.0 # N/A
parser = Parser() parser = Parser()
deck = parser.parse('tests/data/JFUNC.DATA') deck = parser.parse(test_path('data/JFUNC.DATA'))
js = EclipseState(deck) js = EclipseState(deck)
self.assertEqual('JFUNC TEST', js.title) self.assertEqual('JFUNC TEST', js.title)
jf = js.jfunc() jf = js.jfunc()

View File

@@ -3,7 +3,10 @@ import datetime
from opm.tools import * from opm.tools import *
from opm.io.parser import Parser from opm.io.parser import Parser
from utils import test_path, tmp try:
from tests.utils import test_path, tmp
except ImportError:
from utils import test_path, tmp
class TestTimeVector(unittest.TestCase): class TestTimeVector(unittest.TestCase):

View File

@@ -3,7 +3,11 @@ import opm
from opm.io.parser import Parser from opm.io.parser import Parser
from opm.io.ecl_state import EclipseState from opm.io.ecl_state import EclipseState
from opm.io.schedule import Schedule from opm.io.schedule import Schedule
from utils import test_path
try:
from tests.utils import test_path
except ImportError:
from utils import test_path
def injector(well): def injector(well):
return well.isinjector() return well.isinjector()