# Path: molmod/test/common.py
# @contextmanager
# def tmpdir(suffix, prefix):
#     dn = tempfile.mkdtemp(suffix, prefix)
#     try:
#         yield dn
#     finally:
#         shutil.rmtree(dn)


import os
import unittest
import shutil
import stat
import subprocess
import tempfile
import pkg_resources
from molmod import *
from molmod.test.common import tmpdir
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>
#
# --


from __future__ import print_function





def check_example(dirname, fn_script, fns_data):
    """Run an example in a temporary directory and check its exit code.

    Parameters
    ----------
    dirname : str
        The directory with the example, relative to the __file__ of where you call this
        function.
    fn_script : str
        The name of the script to be executed, assumed to be present in the given
        directory.
    fns_data : list of str:
        A list of data files needed by the example, which will be copied over to the
        temporary directory.
    """

# Path: molmod/test/common.py
# @contextmanager
# def tmpdir(suffix, prefix):
#     dn = tempfile.mkdtemp(suffix, prefix)
#     try:
#         yield dn
#     finally:
#         shutil.rmtree(dn)


# Path: molmod/test/test_examples.py
import os
import unittest
import shutil
import stat
import subprocess
import tempfile
import pkg_resources
from molmod import *
from molmod.test.common import tmpdir

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>
#
# --


from __future__ import print_function





def check_example(dirname, fn_script, fns_data):
    """Run an example in a temporary directory and check its exit code.

    Parameters
    ----------
    dirname : str
        The directory with the example, relative to the __file__ of where you call this
        function.
    fn_script : str
        The name of the script to be executed, assumed to be present in the given
        directory.
    fns_data : list of str:
        A list of data files needed by the example, which will be copied over to the
        temporary directory.
    """

    with tmpdir(__name__, dirname + fn_script) as dntmp: