示例#1
0
def test_ensure_cache_exception_safety(mocked_cache):
    cache_file = mocked_cache.join('test.txt')
    with pytest.raises(BoomError):
        rubyvenv.ensure_cache_file('test.txt', RaisesAfterSomeIO)
    assert not cache_file.exists()
    assert mocked_cache.join('tmp').listdir() == []
示例#2
0
def test_ensure_cache_file_file_does_not_exist(mocked_cache):
    cache_file = mocked_cache.join('test.txt')
    ret = rubyvenv.ensure_cache_file('test.txt', _fileobj_func(b'bar'))
    assert ret == cache_file.strpath
    assert cache_file.read() == 'bar'
示例#3
0
def test_ensure_cache_file_makes_directories(mocked_cache):
    cache_file = mocked_cache.join('dir/test.txt')
    ret = rubyvenv.ensure_cache_file('dir/test.txt', _fileobj_func(b'bar'))
    assert ret == cache_file.strpath
    assert cache_file.read() == 'bar'
示例#4
0
def test_ensure_cache_file_file_exists(mocked_cache):
    cache_file = mocked_cache.ensure_dir().join('test.txt')
    cache_file.write('foo')
    ret = rubyvenv.ensure_cache_file('test.txt', _fileobj_func(b'bar'))
    assert ret == cache_file.strpath
    assert cache_file.read() == 'foo'