# Path: tests/datafiles.py
# def datafile(name):
#     return resource_filename(__name__, os.path.join("data", name))


import gromacs
import pytest
from numpy.testing import assert_equal
from ..datafiles import datafile
    def test_comments(self, CUSTOM_EM_MDP):
        mdp, _ = CUSTOM_EM_MDP

        assert mdp['C0001'] == 'custom EM'
        assert sum(1 for k in mdp if k.startswith('C0')) == 1

    def test_blank_lines(self, CUSTOM_EM_MDP):
        mdp, _ = CUSTOM_EM_MDP
        assert sum(1 for k in mdp if k.startswith('B0')) == 6

    def test_no_filename(self, tmpdir):
        mdp = gromacs.fileformats.mdp.MDP()

        mdp['define'] = ['-DPOSRES', '-DTHIS']
        mdp['vdwtype'] = 'cutoff'
        mdp['nsteps'] = 1234

        out = str(tmpdir.join('out.mdp'))
        mdp.write(out)

        back = gromacs.fileformats.mdp.MDP(out)

        assert_equal(back['define'], ['-DPOSRES', '-DTHIS'])
        assert back['vdwtype'] == 'cutoff'
        assert back['nsteps'] == 1234

@pytest.fixture
def NONSENSE_MDP(tmpdir):
    outfile = str(tmpdir.join('nonsense.mdp'))


# Path: tests/datafiles.py
# def datafile(name):
#     return resource_filename(__name__, os.path.join("data", name))


# Path: tests/fileformats/test_mdp.py
import gromacs
import pytest
from numpy.testing import assert_equal
from ..datafiles import datafile

    def test_comments(self, CUSTOM_EM_MDP):
        mdp, _ = CUSTOM_EM_MDP

        assert mdp['C0001'] == 'custom EM'
        assert sum(1 for k in mdp if k.startswith('C0')) == 1

    def test_blank_lines(self, CUSTOM_EM_MDP):
        mdp, _ = CUSTOM_EM_MDP
        assert sum(1 for k in mdp if k.startswith('B0')) == 6

    def test_no_filename(self, tmpdir):
        mdp = gromacs.fileformats.mdp.MDP()

        mdp['define'] = ['-DPOSRES', '-DTHIS']
        mdp['vdwtype'] = 'cutoff'
        mdp['nsteps'] = 1234

        out = str(tmpdir.join('out.mdp'))
        mdp.write(out)

        back = gromacs.fileformats.mdp.MDP(out)

        assert_equal(back['define'], ['-DPOSRES', '-DTHIS'])
        assert back['vdwtype'] == 'cutoff'
        assert back['nsteps'] == 1234

@pytest.fixture
def NONSENSE_MDP(tmpdir):
    outfile = str(tmpdir.join('nonsense.mdp'))


    with open(datafile('custom_em.mdp'), 'r') as infile: