2019-06-04 05:59:06 -05:00
|
|
|
import pytest
|
|
|
|
import sys
|
|
|
|
import os
|
2019-06-05 08:45:22 -05:00
|
|
|
import getopt
|
2019-06-04 05:59:06 -05:00
|
|
|
|
2019-06-12 01:29:41 -05:00
|
|
|
sys.path.insert(1, os.path.join(sys.path[0], '../../'))
|
2019-06-04 05:59:06 -05:00
|
|
|
import rips
|
|
|
|
|
2019-06-05 08:45:22 -05:00
|
|
|
_rips_instance = None
|
2019-06-04 13:35:30 -05:00
|
|
|
|
2019-06-04 05:59:06 -05:00
|
|
|
@pytest.fixture
|
|
|
|
def rips_instance():
|
2019-06-05 08:45:22 -05:00
|
|
|
return _rips_instance
|
2019-06-04 05:59:06 -05:00
|
|
|
|
2019-06-04 13:35:30 -05:00
|
|
|
@pytest.fixture
|
2019-09-19 06:25:04 -05:00
|
|
|
def initialize_test():
|
2019-08-08 01:15:04 -05:00
|
|
|
_rips_instance.project.close() # make sure ResInsight is clean before execution of test
|
2019-09-19 06:25:04 -05:00
|
|
|
yield initialize_test
|
2019-08-08 01:15:04 -05:00
|
|
|
_rips_instance.project.close() # make sure ResInsight is clean after test
|
2019-06-05 08:45:22 -05:00
|
|
|
|
|
|
|
def pytest_addoption(parser):
|
|
|
|
parser.addoption("--console", action="store_true", default=False, help="Run as console application")
|
2019-06-06 02:12:44 -05:00
|
|
|
parser.addoption("--existing", action="store_true", default=False, help="Look for existing ResInsight")
|
2019-06-04 13:35:30 -05:00
|
|
|
|
2019-06-05 08:45:22 -05:00
|
|
|
def pytest_configure(config):
|
|
|
|
global _rips_instance
|
|
|
|
console = False
|
2019-06-06 02:12:44 -05:00
|
|
|
if config.getoption('--existing'):
|
|
|
|
print("Looking for existing ResInsight")
|
|
|
|
_rips_instance = rips.Instance.find()
|
2019-06-06 02:13:23 -05:00
|
|
|
else:
|
|
|
|
if config.getoption('--console'):
|
|
|
|
console = True
|
2019-06-06 02:12:44 -05:00
|
|
|
_rips_instance = rips.Instance.launch(console=console)
|
|
|
|
if not _rips_instance:
|
|
|
|
print("Need a valid ResInsight executable to launch tests")
|
|
|
|
exit(0)
|
2019-06-06 06:48:59 -05:00
|
|
|
|
2019-07-30 04:55:13 -05:00
|
|
|
def pytest_unconfigure(config):
|
|
|
|
if not config.getoption('--existing'):
|
2019-08-22 04:11:16 -05:00
|
|
|
_rips_instance.exit()
|