def test_hash_file_propagates_open_exceptions(tmpdir): """ Any errors raised by opening the path passed to hash_file that aren't ENOENT are propagated upward. """ f = tmpdir.join('f') f.write('') f.chmod(0) with pytest.raises(IOError): runit_sv.hash_file(f.strpath)
def test_hash_file_nonextant_files(tmpdir): """ If the path passed to hash_file doesn't refer to any extant thing, (None, None) is returned. """ f = tmpdir.join('f') assert runit_sv.hash_file(f.strpath) == (None, None)
def test_hash_file(tmpdir, data, expected, mode): """ hash_file will return the hex SHA256 digest and mode of a regular file. """ f = tmpdir.join('f') f.write(data) f.chmod(mode) h, m = runit_sv.hash_file(f.strpath) assert h == expected and m & runit_sv.SETTABLE_MASK == mode