Решение на In-memory файлова система от Йордан Русев

Обратно към всички решения

Към профила на Йордан Русев

Резултати

  • 1 точка от тестове
  • 0 бонус точки
  • 1 точка общо
  • 1 успешни тест(а)
  • 17 неуспешни тест(а)

Код

class File:
def __init__(self, text):
self.content = text
self.is_directory = False
def append(self, text):
self.content = self.content + text
def truncate(self, text):
self.content = text
def size(self):
return len(self.content) + 1
class Folder:
def __init__(self, dir1=None, dir2=None):
self.is_directory = True
self.directories = dir1
self.files = dir2
self.nodes = dir1.extend(dir2)
class FileSystem:
def __init__(self, bytes):
self.size = bytes
self.available_size = bytes - 1
def create(self, path, directory=False, content=''):
if not directory:
self.available_size = self.available_size - len(content) - 1
else:
self.available_size = self.available_size - 1

Лог от изпълнението

EEEEEEE.EEEEEEEEEE
======================================================================
ERROR: test_create_directory (test.TestFileSystem)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 65, in thread
    raise TimeoutError
TimeoutError

======================================================================
ERROR: test_create_file (test.TestFileSystem)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 65, in thread
    raise TimeoutError
TimeoutError

======================================================================
ERROR: test_hard_link_create (test.TestFileSystem)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 65, in thread
    raise TimeoutError
TimeoutError

======================================================================
ERROR: test_hard_link_space_consumption (test.TestFileSystem)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 65, in thread
    raise TimeoutError
TimeoutError

======================================================================
ERROR: test_hard_link_to_directory (test.TestFileSystem)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 65, in thread
    raise TimeoutError
TimeoutError

======================================================================
ERROR: test_hard_link_to_missing_file (test.TestFileSystem)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 65, in thread
    raise TimeoutError
TimeoutError

======================================================================
ERROR: test_link_create (test.TestFileSystem)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 65, in thread
    raise TimeoutError
TimeoutError

======================================================================
ERROR: test_mounting (test.TestFileSystem)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 65, in thread
    raise TimeoutError
TimeoutError

======================================================================
ERROR: test_move_not_to_a_directory (test.TestFileSystem)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 65, in thread
    raise TimeoutError
TimeoutError

======================================================================
ERROR: test_move_overwrite (test.TestFileSystem)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 65, in thread
    raise TimeoutError
TimeoutError

======================================================================
ERROR: test_out_of_space (test.TestFileSystem)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 65, in thread
    raise TimeoutError
TimeoutError

======================================================================
ERROR: test_overwrite (test.TestFileSystem)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 65, in thread
    raise TimeoutError
TimeoutError

======================================================================
ERROR: test_remove_empty_directory (test.TestFileSystem)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 65, in thread
    raise TimeoutError
TimeoutError

======================================================================
ERROR: test_remove_file (test.TestFileSystem)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 65, in thread
    raise TimeoutError
TimeoutError

======================================================================
ERROR: test_remove_nonempty_directory (test.TestFileSystem)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 65, in thread
    raise TimeoutError
TimeoutError

======================================================================
ERROR: test_symlink_to_missing_file (test.TestFileSystem)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 65, in thread
    raise TimeoutError
TimeoutError

======================================================================
ERROR: test_valid_move (test.TestFileSystem)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 65, in thread
    raise TimeoutError
TimeoutError

----------------------------------------------------------------------
Ran 18 tests in 34.130s

FAILED (errors=17)

История (1 версия и 0 коментара)

Йордан обнови решението на 30.04.2015 16:40 (преди около 9 години)

+class File:
+ def __init__(self, text):
+ self.content = text
+ self.is_directory = False
+
+ def append(self, text):
+ self.content = self.content + text
+
+ def truncate(self, text):
+ self.content = text
+
+ def size(self):
+ return len(self.content) + 1
+
+
+class Folder:
+ def __init__(self, dir1=None, dir2=None):
+ self.is_directory = True
+ self.directories = dir1
+ self.files = dir2
+ self.nodes = dir1.extend(dir2)
+
+
+class FileSystem:
+ def __init__(self, bytes):
+ self.size = bytes
+ self.available_size = bytes - 1
+
+ def create(self, path, directory=False, content=''):
+ if not directory:
+ self.available_size = self.available_size - len(content) - 1
+ else:
+ self.available_size = self.available_size - 1