From ed2c3ea45118cdb13ac001520b5684d4bb1ea2c3 Mon Sep 17 00:00:00 2001 From: Axel Dahlberg Date: Sun, 17 Jan 2021 13:24:49 +0100 Subject: Update to test cleanup file context and ignore cover --- tests/unit/utils/test_utils.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'tests/unit/utils/test_utils.py') diff --git a/tests/unit/utils/test_utils.py b/tests/unit/utils/test_utils.py index 525b99550..74b49f573 100644 --- a/tests/unit/utils/test_utils.py +++ b/tests/unit/utils/test_utils.py @@ -882,27 +882,25 @@ def test_mimetype_extension(mimetype, extension): class TestCleanupFileContext: - def test_no_file(self, tmpdir): - tmpfile = tmpdir / 'tmp.txt' + def test_no_file(self, tmp_path): + tmpfile = tmp_path / 'tmp.txt' with utils.cleanup_file(tmpfile): pass - assert not os.path.exists(tmpfile) + assert not tmpfile.exists() - def test_no_error(self, tmpdir): - tmpfile = tmpdir / 'tmp.txt' + def test_no_error(self, tmp_path): + tmpfile = tmp_path / 'tmp.txt' with tmpfile.open('w'): pass with utils.cleanup_file(tmpfile): pass - assert not os.path.exists(tmpfile) + assert not tmpfile.exists() - def test_error(self, tmpdir): - tmpfile = tmpdir / 'tmp.txt' + def test_error(self, tmp_path): + tmpfile = tmp_path / 'tmp.txt' with tmpfile.open('w'): pass - try: + with pytest.raises(RuntimeError): with utils.cleanup_file(tmpfile): raise RuntimeError - except RuntimeError: - pass - assert not os.path.exists(tmpfile) + assert not tmpfile.exists() -- cgit v1.2.3-54-g00ecf