def test_create_files_same_dir(): fs = FakeFileSystem() fs.create_dir('test-dir') fs.create_file('test-dir/hi.txt', 'hi') fs.create_file('test-dir/hello.txt', 'hello') with fs.open('test-dir/hi.txt') as f: assert f.read() == 'hi' with fs.open('test-dir/hello.txt') as f: assert f.read() == 'hello'
def test_create_dir_and_file(): fs = FakeFileSystem() fs.create_dir('/plugins/portals') dependency_file_content = 'fileupload\nunderscore\n' fs.create_file('/plugins/portals/dependencies', dependency_file_content) with fs.open('/plugins/portals/dependencies') as f: dependency_names = f.read().splitlines() assert dependency_names[0] == 'fileupload'
def test_open_unexisting_file_throws_error(): fs = FakeFileSystem() with raises(IOError): fs.open('plugins/a.txt')