def testInParentDir(self, restore_cwd): os.chdir(os.path.join(os.path.dirname(__file__), "data")) fileName = "loader_sample.py" pytest.raises(InvalidDodoFile, get_module, fileName) get_module(fileName, seek_parent=True) # cwd is changed to location of dodo.py assert os.getcwd() == os.path.dirname(os.path.abspath(fileName))
def testSetCwd(self, restore_cwd): initial_wd = os.getcwd() fileName = os.path.join(os.path.dirname(__file__),"loader_sample.py") cwd = os.path.join(os.path.dirname(__file__), "data") assert cwd != initial_wd # make sure test is not too easy get_module(fileName, cwd) assert os.getcwd() == cwd, os.getcwd() assert doit.get_initial_workdir() == initial_wd
def testRelativePath(self, restore_cwd): # test relative import but test should still work from any path # so change cwd. this_path = os.path.join(os.path.dirname(__file__),'..') os.chdir(os.path.abspath(this_path)) fileName = "tests/loader_sample.py" dodo_module = get_module(fileName) assert hasattr(dodo_module, 'task_xxx1')
def testRelativePath(self): # test relative import but test should still work from any path # so change cwd. os.chdir(os.path.abspath(os.path.join(os.path.dirname(__file__),'..'))) fileName = "tests/loader_sample.py" expected = ["xxx1","yyy2"] dodo_module = get_module(fileName) dodo = load_task_generators(dodo_module) assert expected == [t.name for t in dodo['task_list']]
def load_tasks(self, cmd, opt_values, pos_args): makeitcfg = self.cfg.get('makeit') if not hasattr(makeitcfg, 'get'): raise RuntimeError('Configuration must have a [makeit] section') mods = [] modpath = makeitcfg.get('path').split(':') self.doitcfg.update(self.cfg.get('doit', {})) # Find absolute paths to task modules loadpaths = self._search_module_paths(modpath) # Load task generators from modules for path in loadpaths: mods.append(get_module(path)) taskgens = self._collect_taskgens(mods) # Generate task dicts taskdicts = self._taskgens_to_dicts(taskgens) # Process makeit extensions out of task dicts processed = self._process_makeit_extensions(taskdicts) # Generate Task objects from processed tasks return self._processed_dicts_to_tasks(processed), self.doitcfg
def testAbsolutePath(self, restore_cwd): fileName = os.path.join(os.path.dirname(__file__),"loader_sample.py") dodo_module = get_module(fileName) assert hasattr(dodo_module, 'task_xxx1')
def testSetCwd(self, cwd): fileName = os.path.join(os.path.dirname(__file__),"loader_sample.py") cwd = os.path.join(os.path.dirname(__file__), "data") get_module(fileName, cwd) assert os.getcwd() == cwd, os.getcwd()
def testAbsolutePath(self, cwd): #FIXME funcarg should be for loader_sample fileName = os.path.join(os.path.dirname(__file__),"loader_sample.py") expected = ["xxx1","yyy2"] dodo_module = get_module(fileName) dodo = load_task_generators(dodo_module) assert expected == [t.name for t in dodo['task_list']]
def get_dodo_module(): fileName = os.path.join(os.path.dirname(__file__), "loader_sample.py") return get_module(fileName)
def testDocString(self, cwd): fileName = os.path.join(os.path.dirname(__file__),"loader_sample.py") dodo_module = get_module(fileName) dodo = load_task_generators(dodo_module) assert "task doc" == dodo['task_list'][0].doc, dodo['task_list'][0].doc
def testNameInBlacklist(self, cwd): fileName = os.path.join(os.path.dirname(__file__),"loader_sample.py") dodo_module = get_module(fileName) pytest.raises(InvalidDodoFile, load_task_generators, dodo_module, ['yyy2'])
def testSetCwd(self, cwd): fileName = os.path.join(os.path.dirname(__file__), "loader_sample.py") cwd = os.path.join(os.path.dirname(__file__), "data") get_module(fileName, cwd) assert os.getcwd() == cwd, os.getcwd()