def test_file_read_rb(mounted_fs): fh = lfs.file_open(mounted_fs, 'test.txt', 'w') lfs.file_write(mounted_fs, fh, b'0123456789') lfs.file_close(mounted_fs, fh) fh = lfs.file_open(mounted_fs, 'test.txt', 'rb') data = lfs.file_read(mounted_fs, fh, 10) assert data == b'0123456789'
def test_file_open_exist(mounted_fs): fh = lfs.file_open(mounted_fs, 'test.txt', 'wb') lfs.file_write(mounted_fs, fh, b'0123456789') lfs.file_close(mounted_fs, fh) with pytest.raises(LittleFSError) as excinfo: fh = lfs.file_open(mounted_fs, 'test.txt', 'x') assert excinfo.value.code == LittleFSError.Error.LFS_ERR_EXIST
def test_stat_file(mounted_fs): fh = lfs.file_open(mounted_fs, 'test.txt', 'w') lfs.file_write(mounted_fs, fh, b'0123456789') lfs.file_close(mounted_fs, fh) stat = lfs.stat(mounted_fs, 'test.txt') assert stat.size == 10 assert stat.type == 1 assert stat.name == 'test.txt'
def test_file_open_a(mounted_fs): fh = lfs.file_open(mounted_fs, 'test.txt', 'w') lfs.file_write(mounted_fs, fh, b'0123456789') lfs.file_close(mounted_fs, fh) fh = lfs.file_open(mounted_fs, 'test.txt', 'a') lfs.file_write(mounted_fs, fh, b'0123456789') lfs.file_close(mounted_fs, fh) info = lfs.stat(mounted_fs, 'test.txt') assert info.size == 20
def test_file_close(mounted_fs): fh = lfs.file_open(mounted_fs, 'test.txt', 'w') lfs.file_close(mounted_fs, fh)