# HG changeset patch # User Atul Varma # Date 1273481699 25200 # Node ID 3897ed8a350debed3312ffa194ea8e13c75693fc # Parent 83104982c815aa44bcfc4688302e3b33786df1da Added NullFileSystem and test for it. diff -r 83104982c815 -r 3897ed8a350d pydertron/__init__.py --- a/pydertron/__init__.py Mon May 10 01:20:21 2010 -0700 +++ b/pydertron/__init__.py Mon May 10 01:54:59 2010 -0700 @@ -591,6 +591,17 @@ e.exc_info[2], None, stderr) return retval +class NullFileSystem(object): + """ + File system that represents an empty filesystem. + """ + + def find_module(self, curr_script, path): + return None + + def open(self, filename): + raise AssertionError('This should never be called.') + class HttpFileSystem(object): """ File system through which all resources are loaded over HTTP. diff -r 83104982c815 -r 3897ed8a350d test_pydertron.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test_pydertron.py Mon May 10 01:54:59 2010 -0700 @@ -0,0 +1,18 @@ +import unittest +from StringIO import StringIO + +import pydertron + +class PydertronTests(unittest.TestCase): + def testNullFilesystem(self): + stderr = StringIO() + sandbox = pydertron.JsSandbox(pydertron.NullFileSystem()) + sandbox.set_globals() + sandbox.run_script("require('hi');", stderr=stderr) + self.assertEqual(stderr.getvalue(), + 'Traceback (most recent call last):\n' + ' File "", line 1, in \n' + 'Module not found: hi\n') + +if __name__ == '__main__': + unittest.main()