Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joelb123 committed Sep 30, 2020
1 parent 560e794 commit fe57c4a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 35 deletions.
37 changes: 20 additions & 17 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,23 @@ Test ``datadir-mgr`` with ``poetry``: ::

Project Status
--------------
+-------------------+------------+
| Latest Release | |pypi| |
+-------------------+------------+
| GitHub | |repo| |
+-------------------+------------+
| License | |license| |
+-------------------+------------+
| Travis Build | |travis| |
+-------------------+------------+
| Coverage | |coverage| |
+-------------------+------------+
| Code Grade | |codacy| |
+-------------------+------------+
| Dependencies | |depend| |
+-------------------+------------+
| Issues | |issues| |
+-------------------+------------+
+-------------------+-------------+
| Latest Release | |pypi| |
+-------------------+-------------+
| Activity | |downloads| |
+-------------------+-------------+
| License | |license| |
+-------------------+-------------+
| Travis Build | |travis| |
+-------------------+-------------+
| Coverage | |coverage| |
+-------------------+-------------+
| Code Grade | |codacy| |
+-------------------+-------------+
| Dependencies | |depend| |
+-------------------+-------------+
| Issues | |issues| |
+-------------------+-------------+

.. _pytest: http://pytest.org/

Expand Down Expand Up @@ -117,3 +117,6 @@ Project Status
:target: https://app.dependabot.com/accounts/legumeinfo/repos/236847525
:alt: dependabot dependencies

.. |downloads| image:: https://pepy.tech/badge/pytest_datadir_mgr
:target: https://pepy.tech/project/pytest_datadir_mgr
:alt: Download stats
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pytest-datadir-mgr"
version = "1.1.3"
version = "1.2.1"
description = "Manager for test data providing downloads, caching of generated files, and a context for temp directories."
authors = ["Joel Berendzen <joelb@ncgr.org>"]
license = "BSD-3-Clause"
Expand Down
2 changes: 1 addition & 1 deletion pytest_datadir_mgr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"module",
"global",
) # ordered from lowest to highest
__version__ = "1.1.3"
__version__ = "1.2.1"


class DataDirManager:
Expand Down
34 changes: 18 additions & 16 deletions tests/2_module_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,25 @@ def test_empty_tmp_dir(datadir_mgr):
filehandle.write(NEWMSG)


def test_in_tmp_dir(datadir_mgr):
def test_in_tmp_dir(datadir_mgr, capsys):
"""Test using context manager with saved data."""
with datadir_mgr.in_tmp_dir(
inpathlist=[DLFILE, TESTFILE],
save_outputs=True,
outscope="function",
excludepatterns=["*.log"],
):
data1 = open(datadir_mgr[TESTFILE]).read()
dlpath = Path(DLFILE)
assert data1 == "data at module scope\n"
assert dlpath.exists()
NEWPATH.parent.mkdir(parents=True, exist_ok=True)
with NEWPATH.open("w") as filehandle:
filehandle.write(NEWMSG)
with LOGPATH.open("w") as logfilehandle:
logfilehandle.write("here is a log file")
with capsys.disabled():
with datadir_mgr.in_tmp_dir(
inpathlist=[DLFILE, TESTFILE],
save_outputs=True,
outscope="function",
excludepatterns=["*.log"],
progressbar=True,
):
data1 = open(datadir_mgr[TESTFILE]).read()
dlpath = Path(DLFILE)
assert data1 == "data at module scope\n"
assert dlpath.exists()
NEWPATH.parent.mkdir(parents=True, exist_ok=True)
with NEWPATH.open("w") as filehandle:
filehandle.write(NEWMSG)
with LOGPATH.open("w") as logfilehandle:
logfilehandle.write("here is a log file")
assert not dlpath.exists()


Expand Down

0 comments on commit fe57c4a

Please sign in to comment.