import numpy as np
import openmc
from pkg_resources import parse_version
import pytest


@pytest.fixture(scope='module', autouse=True)
def numpy_version_requirement():
    assert parse_version(np.__version__) >= parse_version("1.14"), \
        "Regression tests require NumPy 1.14 or greater"


@pytest.fixture(scope='module', autouse=True)
def setup_regression_test(request):
    # Reset autogenerated IDs assigned to OpenMC objects
    openmc.reset_auto_ids()

    # Change to test directory
    olddir = request.fspath.dirpath().chdir()
    try:
        yield
    finally:
        olddir.chdir()
