# Path: paratemp/tools.py
# @contextmanager
# def cd(new_dir):
#     prev_dir = os.getcwd()
#     os.chdir(os.path.expanduser(new_dir))
#     try:
#         yield
#     finally:
#         os.chdir(prev_dir)


import pathlib
import pytest
from paratemp.tools import cd
        from paratemp.sim_setup import Simulation
        from paratemp.sim_setup import Simulation
    @pytest.mark.parametrize('step', list(mdps.keys()))
    def test_methods_exist_and_callable(self, sim, step):
        assert hasattr(sim, step)
        assert callable(getattr(sim, step))

    def test_fp(self, sim):
        sample_file = 'tests/__init__.py'
        fp = sim._fp(sample_file)
        assert fp.exists()
        assert fp.is_absolute()
        assert fp.is_file()
        assert fp.samefile(sample_file)

    def test_last_geom(self, sim):
        gro = sim.last_geometry
        assert isinstance(gro, pathlib.Path)
        assert gro.suffix == '.gro'
        assert gro.is_absolute()
        assert gro.is_file()

    def test_next_folder_index(self, sim):
        assert sim._next_folder_index == 1
        path = sim.base_folder
        with cd(path):
            path.joinpath('01-minimize-phen').mkdir()
            path.joinpath('02-equil-phen').mkdir()
        assert sim._next_folder_index == 3
        with cd(path):
            path.joinpath('05-step-mol').mkdir()
        assert sim._next_folder_index == 6

# Path: paratemp/tools.py
# @contextmanager
# def cd(new_dir):
#     prev_dir = os.getcwd()
#     os.chdir(os.path.expanduser(new_dir))
#     try:
#         yield
#     finally:
#         os.chdir(prev_dir)


# Path: tests/test_sim_setup/test_simulation.py
import pathlib
import pytest
from paratemp.tools import cd
        from paratemp.sim_setup import Simulation
        from paratemp.sim_setup import Simulation

    @pytest.mark.parametrize('step', list(mdps.keys()))
    def test_methods_exist_and_callable(self, sim, step):
        assert hasattr(sim, step)
        assert callable(getattr(sim, step))

    def test_fp(self, sim):
        sample_file = 'tests/__init__.py'
        fp = sim._fp(sample_file)
        assert fp.exists()
        assert fp.is_absolute()
        assert fp.is_file()
        assert fp.samefile(sample_file)

    def test_last_geom(self, sim):
        gro = sim.last_geometry
        assert isinstance(gro, pathlib.Path)
        assert gro.suffix == '.gro'
        assert gro.is_absolute()
        assert gro.is_file()

    def test_next_folder_index(self, sim):
        assert sim._next_folder_index == 1
        path = sim.base_folder
        with cd(path):
            path.joinpath('01-minimize-phen').mkdir()
            path.joinpath('02-equil-phen').mkdir()
        assert sim._next_folder_index == 3
        with cd(path):
            path.joinpath('05-step-mol').mkdir()
        assert sim._next_folder_index == 6

        with cd(path):