Esempio n. 1
0
 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))
Esempio n. 2
0
 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))
Esempio n. 3
0
 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
Esempio n. 4
0
 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
Esempio n. 5
0
 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')
Esempio n. 6
0
 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')
Esempio n. 7
0
 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']]
Esempio n. 8
0
 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
Esempio n. 9
0
 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')
Esempio n. 10
0
 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()
Esempio n. 11
0
 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')
Esempio n. 12
0
 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']]
Esempio n. 13
0
 def get_dodo_module():
     fileName = os.path.join(os.path.dirname(__file__),
                             "loader_sample.py")
     return get_module(fileName)
Esempio n. 14
0
 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
Esempio n. 15
0
 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'])
Esempio n. 16
0
 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()