Commit c684b3db authored by Matt Clarkson's avatar Matt Clarkson

Issue #8: Added extra unit tests to ensure validate_is_writable_file will...

Issue #8: Added extra unit tests to ensure validate_is_writable_file will indicate if a file is unwritable.
parent aad7c0bd
Pipeline #699 passed with stages
in 7 minutes and 48 seconds
......@@ -4,6 +4,7 @@
Tests for file_utilities.py
"""
import os
import pytest
from sksurgerycore.utilities import validate_file as f
......@@ -48,3 +49,23 @@ def test_valid_writeable_file():
result = f.validate_is_writable_file("tests/data/FordPrefect.json")
assert result
def test_invalid_writeable_file_as_its_not_writeable():
output_dir = 'tests/output'
if not os.path.exists(output_dir):
os.mkdir(output_dir)
file_name = os.path.join(output_dir, 'unwriteable.txt')
with open(file_name, 'w') as out_file:
out_file.write('Hello world')
os.chmod(file_name, 0o400)
with pytest.raises(ValueError):
f.validate_is_writable_file(file_name)
os.chmod(file_name, 0o600)
os.remove(file_name)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment