# Path: rave/filesystem.py
# PATH_SEPARATOR = '/'
# ROOT = '/'
# BAD_PATH_PATTERN = re.compile(r'(?:{0}{{2,}}|(?:{0}|^)\.+(?:{0}|$))'.format(PATH_SEPARATOR))
# ENGINE_MOUNT = '/.rave'
# MODULE_MOUNT = '/.modules'
# GAME_MOUNT = '/'
# COMMON_MOUNT = '/.common'
# class FileSystemError(rave.common.raveError, IOError):
# class NativeError(FileSystemError):
# class FileNotFound(FileSystemError, FileNotFoundError):
# class AccessDenied(FileSystemError, PermissionError):
# class FileNotReadable(FileSystemError, PermissionError, io.UnsupportedOperation):
# class FileNotWritable(FileSystemError, PermissionError, io.UnsupportedOperation):
# class FileNotSeekable(FileSystemError, PermissionError, io.UnsupportedOperation):
# class FileClosed(FileSystemError, BrokenPipeError):
# class NotAFile(FileSystemError, IsADirectoryError):
# class NotADirectory(FileSystemError, NotADirectoryError):
# class FileSystem:
# class File(io.IOBase):
# class FileSystemProvider:
#     def __init__(self, filename, message=None):
#     def __init__(self, filename, parent):
#     def __init__(self):
#     def __repr__(self):
#     def clear(self):
#     def _build_cache(self):
#     def _build_provider_cache(self, provider, root):
#     def _build_transformer_cache(self, transformer, pattern):
#     def _cache_directory(self, provider, root, path):
#     def _cache_file(self, provider, root, path):
#     def _cache_entry(self, provider, root, path):
#     def _cache_transformed_file(self, transformer, path, handle):
#     def _providers_for_file(self, path):
#     def _local_file(self, root, path):
#     def list(self, subdir=None):
#     def listdir(self, subdir=None):
#     def mount(self, path, provider):
#     def unmount(self, path, provider):
#     def transform(self, pattern, transformer):
#     def untransform(self, pattern, transformer):
#     def open(self, filename, *args, **kwargs):
#     def exists(self, filename):
#     def isdir(self, filename):
#     def isfile(self, filename):
#     def dirname(self, path):
#     def basename(self, path):
#     def join(self, *paths, normalized=True):
#     def split(self, path, *args, **kwargs):
#     def normalize(self, path):
#     def __del__(self):
#     def close(self):
#     def opened(self):
#     def readable(self):
#     def writable(self):
#     def seekable(self):
#     def read(self, amount=None):
#     def write(self, data):
#     def seek(self, position, mode=os.SEEK_CUR):
#     def tell(self):
#     def __init__(self, fs):
#     def __repr__(self):
#     def list(self):
#     def open(self, filename, *args, **kwargs):
#     def has(self, filename):
#     def isfile(self, filename):
#     def isdir(self, filename):
# def current():
# def list(subdir=None):
# def listdir(subdir=None):
# def mount(path, provider):
# def unmount(path, provider):
# def transform(pattern, transformer):
# def untransform(pattern, transformer):
# def open(filename, *args, **kwargs):
# def exists(filename):
# def isfile(filename):
# def isdir(filename):
# def dirname(path):
# def basename(path):
# def join(*paths, normalized=True):
# def split(path, *args, **kwargs):
# def normalize(path):


from rave import filesystem
from pytest import raises
from .support.filesystem import *

def test_empty(fs):
	assert fs.list() == { '/' }
	assert fs.listdir('/') == set()

def test_clear(dummyfs):
	dummyfs.clear()
	test_empty(dummyfs)



def test_list(dummyfs):
	assert dummyfs.list() == { '/', '/x', '/x/a.txt', '/x/b.png' }
	assert dummyfs.list('/x') == { '/', '/a.txt', '/b.png' }

def test_list_nested(nestedfs):
	assert nestedfs.list() == { '/', '/x', '/x/y', '/x/y/z', '/x/y/c.txt', '/x/y/p.png' }
	assert nestedfs.list('/x') == { '/', '/y', '/y/z', '/y/c.txt', '/y/p.png' }

def test_list_multiple(doublefs):
	assert doublefs.list() == { '/', '/x', '/x/a.txt', '/x/b.png', '/y', '/y/c.exe', '/y/d.jpg' }

def test_list_merged(mergedfs):
	assert mergedfs.list() == { '/', '/x', '/x/a.txt', '/x/b.png', '/x/c.exe', '/x/d.jpg' }

def test_list_nonexistent(dummyfs):
	with raises(filesystem.FileNotFound):
		dummyfs.list('/nonexistent')

def test_list_file(dummyfs):

# Path: rave/filesystem.py
# PATH_SEPARATOR = '/'
# ROOT = '/'
# BAD_PATH_PATTERN = re.compile(r'(?:{0}{{2,}}|(?:{0}|^)\.+(?:{0}|$))'.format(PATH_SEPARATOR))
# ENGINE_MOUNT = '/.rave'
# MODULE_MOUNT = '/.modules'
# GAME_MOUNT = '/'
# COMMON_MOUNT = '/.common'
# class FileSystemError(rave.common.raveError, IOError):
# class NativeError(FileSystemError):
# class FileNotFound(FileSystemError, FileNotFoundError):
# class AccessDenied(FileSystemError, PermissionError):
# class FileNotReadable(FileSystemError, PermissionError, io.UnsupportedOperation):
# class FileNotWritable(FileSystemError, PermissionError, io.UnsupportedOperation):
# class FileNotSeekable(FileSystemError, PermissionError, io.UnsupportedOperation):
# class FileClosed(FileSystemError, BrokenPipeError):
# class NotAFile(FileSystemError, IsADirectoryError):
# class NotADirectory(FileSystemError, NotADirectoryError):
# class FileSystem:
# class File(io.IOBase):
# class FileSystemProvider:
#     def __init__(self, filename, message=None):
#     def __init__(self, filename, parent):
#     def __init__(self):
#     def __repr__(self):
#     def clear(self):
#     def _build_cache(self):
#     def _build_provider_cache(self, provider, root):
#     def _build_transformer_cache(self, transformer, pattern):
#     def _cache_directory(self, provider, root, path):
#     def _cache_file(self, provider, root, path):
#     def _cache_entry(self, provider, root, path):
#     def _cache_transformed_file(self, transformer, path, handle):
#     def _providers_for_file(self, path):
#     def _local_file(self, root, path):
#     def list(self, subdir=None):
#     def listdir(self, subdir=None):
#     def mount(self, path, provider):
#     def unmount(self, path, provider):
#     def transform(self, pattern, transformer):
#     def untransform(self, pattern, transformer):
#     def open(self, filename, *args, **kwargs):
#     def exists(self, filename):
#     def isdir(self, filename):
#     def isfile(self, filename):
#     def dirname(self, path):
#     def basename(self, path):
#     def join(self, *paths, normalized=True):
#     def split(self, path, *args, **kwargs):
#     def normalize(self, path):
#     def __del__(self):
#     def close(self):
#     def opened(self):
#     def readable(self):
#     def writable(self):
#     def seekable(self):
#     def read(self, amount=None):
#     def write(self, data):
#     def seek(self, position, mode=os.SEEK_CUR):
#     def tell(self):
#     def __init__(self, fs):
#     def __repr__(self):
#     def list(self):
#     def open(self, filename, *args, **kwargs):
#     def has(self, filename):
#     def isfile(self, filename):
#     def isdir(self, filename):
# def current():
# def list(subdir=None):
# def listdir(subdir=None):
# def mount(path, provider):
# def unmount(path, provider):
# def transform(pattern, transformer):
# def untransform(pattern, transformer):
# def open(filename, *args, **kwargs):
# def exists(filename):
# def isfile(filename):
# def isdir(filename):
# def dirname(path):
# def basename(path):
# def join(*paths, normalized=True):
# def split(path, *args, **kwargs):
# def normalize(path):


# Path: tests/test_filesystem_list.py
from rave import filesystem
from pytest import raises
from .support.filesystem import *


def test_empty(fs):
	assert fs.list() == { '/' }
	assert fs.listdir('/') == set()

def test_clear(dummyfs):
	dummyfs.clear()
	test_empty(dummyfs)



def test_list(dummyfs):
	assert dummyfs.list() == { '/', '/x', '/x/a.txt', '/x/b.png' }
	assert dummyfs.list('/x') == { '/', '/a.txt', '/b.png' }

def test_list_nested(nestedfs):
	assert nestedfs.list() == { '/', '/x', '/x/y', '/x/y/z', '/x/y/c.txt', '/x/y/p.png' }
	assert nestedfs.list('/x') == { '/', '/y', '/y/z', '/y/c.txt', '/y/p.png' }

def test_list_multiple(doublefs):
	assert doublefs.list() == { '/', '/x', '/x/a.txt', '/x/b.png', '/y', '/y/c.exe', '/y/d.jpg' }

def test_list_merged(mergedfs):
	assert mergedfs.list() == { '/', '/x', '/x/a.txt', '/x/b.png', '/x/c.exe', '/x/d.jpg' }

def test_list_nonexistent(dummyfs):
	with raises(filesystem.FileNotFound):
		dummyfs.list('/nonexistent')

def test_list_file(dummyfs):

	with raises(filesystem.NotADirectory):