Example #1
0
	def test_loader(self):
		loader = Loader()
		fm = OpenStruct(loader=loader)
		SettingsAware.settings = Fake()
		FileManagerAware.fm = fm

		# initially, the loader has nothing to do
		self.assertFalse(loader.has_work())

		dir = Directory(TESTDIR)
		self.assertEqual(None, dir.files)
		self.assertFalse(loader.has_work())

		# Calling load_content() will enqueue the loading operation.
		# dir is not loaded yet, but the loader has work
		dir.load_content(schedule=True)
		self.assertEqual(None, dir.files)
		self.assertTrue(loader.has_work())

		iterations = 0
		while loader.has_work():
			iterations += 1
			loader.work()
		#print(iterations)
		self.assertNotEqual(None, dir.files)
		self.assertFalse(loader.has_work())
Example #2
0
    def test_loader(self):
        loader = Loader()
        fm = OpenStruct(loader=loader)
        SettingsAware.settings = Fake()
        FileManagerAware.fm = fm

        # initially, the loader has nothing to do
        self.assertFalse(loader.has_work())

        dir = Directory(TESTDIR)
        self.assertEqual(None, dir.files)
        self.assertFalse(loader.has_work())

        # Calling load_content() will enqueue the loading operation.
        # dir is not loaded yet, but the loader has work
        dir.load_content(schedule=True)
        self.assertEqual(None, dir.files)
        self.assertTrue(loader.has_work())

        iterations = 0
        while loader.has_work():
            iterations += 1
            loader.work()
        #print(iterations)
        self.assertNotEqual(None, dir.files)
        self.assertFalse(loader.has_work())
Example #3
0
class benchmark_load(object):
	def __init__(self):
		self.loader = Loader()
		fm = OpenStruct(loader=self.loader)
		SettingsAware.settings = Fake()
		FileManagerAware.fm = fm
		self.dir = Directory(TESTDIR)

	def bm_run(self, n):
		for _ in range(n):
			self.dir.load_content(schedule=True)
			while self.loader.has_work():
				self.loader.work()
Example #4
0
class benchmark_load(object):
    def __init__(self):
        self.loader = Loader()
        fm = OpenStruct(loader=self.loader)
        SettingsAware.settings = Fake()
        FileManagerAware.fm = fm
        self.dir = Directory(TESTDIR)

    def bm_run(self, n):
        for _ in range(n):
            self.dir.load_content(schedule=True)
            while self.loader.has_work():
                self.loader.work()