Commit 3384abc1 authored by Taddeus Kroes's avatar Taddeus Kroes

Fixed unit tests.

parent c6c47384
......@@ -120,7 +120,10 @@ class Importer(Cache):
return replaced
def concatenate(self, files):
def concatenate(self, files, relative_path=False):
#if relative_path:
# files = self.create_full_paths(files, relative_path)
map(assert_file_exists, files)
self.loaded = []
self.import_map = {}
......@@ -153,6 +156,7 @@ class Importer(Cache):
+ 'file "%s".' % (f, path))
concat += self.concatenate(new_imports)
#concat += self.concatenate(new_imports, path)
concat += content
self.loaded += path
......
......@@ -22,7 +22,7 @@ class TestCache(unittest.TestCase):
f.write(name)
f.close()
self.c = Cache(files=['foo', 'bar'], root='baz')
self.c = Cache(files=['foo', 'bar'], root='baz/')
def tearDown(self):
rmtree('baz')
......@@ -49,12 +49,12 @@ class TestCache(unittest.TestCase):
self.assertEqual(self.c.cached, d + 'cached/')
def test___init___custom_root(self):
c = Cache(root='foo')
c = Cache(root='foo/')
self.assertTrue(hasattr(c, 'root'))
self.assertEqual(c.root, d + 'foo/')
def test___init___custom_cached_dir(self):
c = Cache(cached='foo')
c = Cache(cached='foo/')
self.assertTrue(hasattr(c, 'cached'))
self.assertEqual(c.cached, d + 'foo/')
......
......@@ -25,7 +25,7 @@ class TestImporter(unittest.TestCase):
f.write(self.__getattribute__(name))
f.close()
self.importer = Importer('foo')
self.importer = Importer(root='foo/')
def tearDown(self):
shutil.rmtree('foo')
......@@ -35,7 +35,7 @@ class TestImporter(unittest.TestCase):
self.assertEqual(self.importer.extension, '')
def test___init___extension(self):
self.assertEqual(Importer('foo', extension='txt').extension, '.txt')
self.assertEqual(Importer(root='foo/', extension='txt').extension, '.txt')
def test_separate_imports(self):
self.assertEqual(separate_imports(self.none), ([], self.none))
......@@ -52,12 +52,12 @@ class TestImporter(unittest.TestCase):
def test_create_full_paths_alias(self):
self.importer.set_alias('bar', 'none')
self.assertEqual(self.importer.create_full_paths(['@bar']),
self.assertEqual(self.importer.create_full_paths(['.bar']),
[d + 'foo/none'])
self.assertRaises(ValueError, self.importer.create_full_paths,
['@foo'])
['.foo'])
def test_create_full_paths_relative_file(self):
importer = Importer('.')
importer = Importer('')
self.assertEqual(importer.create_full_paths(['none'], d + 'foo/single'),
[d + 'foo/none'])
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment