Skip to content

Commit 3db4354

Browse files
authored
Merge pull request #76 from MDAnalysis/update-tests
update tests
2 parents 9711157 + 4921450 commit 3db4354

3 files changed

Lines changed: 17 additions & 5 deletions

File tree

MDAnalysisData/base.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from os import environ, listdir, makedirs
3232
from os.path import dirname, exists, expanduser, isdir, join, splitext
3333
import hashlib
34-
from pkg_resources import resource_string
34+
import importlib.resources
3535

3636
from tqdm import tqdm
3737

@@ -207,9 +207,8 @@ def _read_description(filename, description_dir='descr'):
207207
"""
208208
# The descr directory should be in the same directory as this file base.py.
209209
# `resource_string` returns bytes, which we need to decode to UTF-8
210-
DESCR = resource_string(__name__,
211-
'{}/{}'.format(description_dir, filename)
212-
).decode("utf-8")
210+
path = importlib.resources.files('MDAnalysisData') / description_dir / filename
211+
DESCR = path.read_bytes().decode("utf-8")
213212
return DESCR
214213

215214

MDAnalysisData/descr/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

MDAnalysisData/tests/test_datasets.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@
2727
# For filetype=topology, the data are downloaded and cached.
2828
# For filetype=trajectory the cached data are used.
2929
# This test is not thread/parallel safe.
30+
#
31+
# These tests are not enabled by default and are only executed with
32+
# `pytest -m online` or `pytest --pyargs MDAnalysisData` because they
33+
# require downloading datasets.
34+
35+
# CURRENT LIMITATIONS:
36+
#
37+
# Assertions related to DESCR will currently only pass on UNIX (and
38+
# not Windows) because of different line ending conventions (UNIX: \n,
39+
# Windows:\r\n); the tests could be rewritten (e.g., use
40+
# `DESCR.split()` to compare words) and using regex for matching the
41+
# first lines.
3042

3143
@pytest.mark.online
3244
@pytest.mark.parametrize('filetype', ('topology', 'trajectory'))
@@ -159,7 +171,7 @@ def test_yiip_equilibrium(traj_len, filetype):
159171

160172
metadata = yiip_equilibrium.ARCHIVE[traj_len]
161173

162-
assert len(data.DESCR) == 1511
174+
assert len(data.DESCR) == 1536
163175
assert data.DESCR.startswith(".. -*- coding: utf-8 -*-\n\n.. _`yiip-equilibrium-dataset`:")
164176

165177
assert os.path.basename(data[filetype]) == metadata[filetype].filename

0 commit comments

Comments
 (0)