summary refs log tree commit diff stats
path: root/test/tc_directory.py
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-11-27 10:49:48 +0100
committerhut <hut@lavabit.com>2009-11-27 10:49:48 +0100
commit9506fb8e79f2d04a1ab78039bacdbee7b22109b5 (patch)
tree3d5c682e9c5032a1c23be6a98c9d3d6e7c8224b5 /test/tc_directory.py
parent5822dff7d91472bf2fc337c68f144e0ce1de09ae (diff)
downloadranger-9506fb8e79f2d04a1ab78039bacdbee7b22109b5.tar.gz
more VROOM
Diffstat (limited to 'test/tc_directory.py')
-rw-r--r--test/tc_directory.py32
1 files changed, 20 insertions, 12 deletions
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
/a> 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409