From cfd22941f712f9728b3354fc98dc57e3b9631d1c Mon Sep 17 00:00:00 2001 From: Darius Makovsky Date: Thu, 25 Jul 2019 10:17:04 +0100 Subject: Expect descend raises VirtualDirectoryError --- tests/internals/storage_vdir_import.py | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/tests/internals/storage_vdir_import.py b/tests/internals/storage_vdir_import.py index b5463af1b..c25ab0cea 100644 --- a/tests/internals/storage_vdir_import.py +++ b/tests/internals/storage_vdir_import.py @@ -310,27 +310,20 @@ def test_bad_symlinks(tmpdir): ] generate_import_root(test_dir, filesys_discription) d.import_files(test_dir) + exp_reason = "not-a-directory" + msg = "descend() failed to raise a VirtualDirectoryError" - try: + with pytest.raises(VirtualDirectoryError, message=msg) as error: d.descend('a', 'l', follow_symlinks=True) - except VirtualDirectoryError as error: - assert error.reason == "not-a-directory" - else: - raise Exception("Should have had a error") + assert error.reason == exp_reason - try: + with pytest.raises(VirtualDirectoryError, message=msg) as error: d.descend('a', 'l') - except VirtualDirectoryError as error: - assert error.reason == "not-a-directory" - else: - raise Exception("Should have had a error") + assert error.reason == exp_reason - try: + with pytest.raises(VirtualDirectoryError, message=msg) as error: d.descend('a', 'f') - except VirtualDirectoryError as error: - assert error.reason == "directory-not-found" - else: - raise Exception("Should have had a error") + assert error.reason == exp_reason # Check symlink logic for edgecases -- cgit v1.2.1