diff options
author | hut <hut@lavabit.com> | 2009-11-27 10:49:48 +0100 |
---|---|---|
committer | hut <hut@lavabit.com> | 2009-11-27 10:49:48 +0100 |
commit | 9506fb8e79f2d04a1ab78039bacdbee7b22109b5 (patch) | |
tree | 3d5c682e9c5032a1c23be6a98c9d3d6e7c8224b5 /test | |
parent | 5822dff7d91472bf2fc337c68f144e0ce1de09ae (diff) | |
download | ranger-9506fb8e79f2d04a1ab78039bacdbee7b22109b5.tar.gz |
more VROOM
Diffstat (limited to 'test')
-rw-r--r-- | test/dirsize_benchmark.py | 2 | ||||
-rw-r--r-- | test/tc_directory.py | 32 |
2 files changed, 22 insertions, 12 deletions
diff --git a/test/dirsize_benchmark.py b/test/dirsize_benchmark.py index 38f0bfd7..5784ee80 100644 --- a/test/dirsize_benchmark.py +++ b/test/dirsize_benchmark.py @@ -24,3 +24,5 @@ for key in paths.keys(): for i in range(4): assert Dirsize.__dict__[algo](key) == paths[key] print("algorithm %s: %20s: %f" % (algo, key, time.time() - t)) + +# a !! diff --git a/test/tc_directory.py b/test/tc_directory.py index 88c7a99e..275e3129 100644 --- a/test/tc_directory.py +++ b/test/tc_directory.py @@ -1,17 +1,22 @@ -import unittest -import sys, os, time +if __name__ == '__main__': + from os.path import abspath, join + import sys + sys.path.append(abspath(join(sys.path[0], '..'))) -sys.path.append(os.path.normpath(os.path.join(os.path.dirname(__file__), '../code'))) -import fsobject, file, directory +from ranger import fsobject +from ranger.file import File +from ranger.directory import Directory -TESTDIR = os.path.realpath(os.path.join(os.path.dirname(__file__), 'testdir')) -TESTFILE = os.path.join(TESTDIR, 'testfile5234148') +from os.path import realpath, join, dirname +TESTDIR = realpath(join(dirname(__file__), 'testdir')) +TESTFILE = join(TESTDIR, 'testfile5234148') NONEXISTANT_DIR = '/this/directory/will/most/certainly/not/exist' +import unittest class Test1(unittest.TestCase): def test_initial_condition(self): # Check for the expected initial condition - dir = directory.Directory(TESTDIR) + dir = Directory(TESTDIR) self.assertEqual(dir.path, TESTDIR) self.assertFalse(dir.content_loaded) @@ -21,8 +26,9 @@ class Test1(unittest.TestCase): self.assertRaises(fsobject.NotLoadedYet, dir.__getitem__, 0) def test_after_content_loaded(self): + import os # Check whether the directory has the correct list of filenames. - dir = directory.Directory(TESTDIR) + dir = Directory(TESTDIR) dir.load_content() self.assertTrue(dir.exists) @@ -41,7 +47,7 @@ class Test1(unittest.TestCase): # build a file object for each file in the list assumed_filenames # and find exactly one equivalent in dir.files for name in assumed_filenames: - f = file.File(name) + f = File(name) f.load() equal = 0 for dirfile in dir.files: @@ -50,7 +56,7 @@ class Test1(unittest.TestCase): self.assertEqual(equal, 1) def test_nonexistant_dir(self): - dir = directory.Directory(NONEXISTANT_DIR) + dir = Directory(NONEXISTANT_DIR) dir.load_content() self.assertTrue(dir.content_loaded) @@ -61,7 +67,7 @@ class Test1(unittest.TestCase): self.assertRaises(fsobject.NotLoadedYet, dir.__getitem__, 0) def test_modify_frozen_clone(self): - dir = directory.Directory(TESTDIR) + dir = Directory(TESTDIR) clone = dir.frozen_clone() # assert that their attributes are equal, except for frozen, which @@ -79,6 +85,8 @@ class Test1(unittest.TestCase): self.assertRaises(fsobject.FrozenException, clone.load_content) def test_load_if_outdated(self): + import os + import time # modify the directory. If the time between the last modification # was within the filesystems resolution of mtime, we should have a re-load. @@ -89,7 +97,7 @@ class Test1(unittest.TestCase): def mtime(): return os.stat(TESTDIR).st_mtime - dir = directory.Directory(TESTDIR) + dir = Directory(TESTDIR) dir.load() # If the modification happens to be in the same second as the |