def setUp(self): """Set up data for unit tests.""" self.cmd = BashCompletion() # Create a temporary directory that we can copy two config files into. # This module can then be passed to BashCompletion so that we don't # have to update the expected output each time we make an interface # change to pyqi. The temporary directory/module structure looks like # the following: # # <temp dir>/ # pyqi_test/ # __init__.py # make_bash_completion.py # make_optparse.py # # Note that <temp dir> is added to sys.path in setUp and then removed # in tearDown. Imports can then function as normal, e.g.: # # import pyqi_test.make_bash_completion # ... # self.temp_module_dir = mkdtemp() self.temp_module_name = 'pyqi_test' self.temp_config_dir = join(self.temp_module_dir, self.temp_module_name) mkdir(self.temp_config_dir) module = _get_cfg_module('pyqi.interfaces.optparse.config') module_dir = dirname(module.__file__) make_bash_completion_fp = join(module_dir, 'make_bash_completion.py') copy(make_bash_completion_fp, self.temp_config_dir) make_optparse_fp = join(module_dir, 'make_optparse.py') copy(make_optparse_fp, self.temp_config_dir) with open(join(self.temp_config_dir, '__init__.py'), 'w') as f: f.write('') sys.path.append(self.temp_module_dir)
def setUp(self): """Set up data for unit tests.""" self.cmd = BashCompletion() # Create a temporary directory that we can copy two config files into. # This module can then be passed to BashCompletion so that we don't # have to update the expected output each time we make an interface # change to pyqi. The temporary directory/module structure looks like # the following: # # <temp dir>/ # pyqi_test/ # __init__.py # make_bash_completion.py # make_optparse.py # # Note that <temp dir> is added to sys.path in setUp and then removed # in tearDown. Imports can then function as normal, e.g.: # # import pyqi_test.make_bash_completion # ... # self.temp_module_dir = mkdtemp() self.temp_module_name = 'pyqi_test' self.temp_config_dir = join(self.temp_module_dir, self.temp_module_name) mkdir(self.temp_config_dir) module = _get_cfg_module('pyqi.interfaces.optparse.config') module_dir = dirname(module.__file__) make_bash_completion_fp = join(module_dir, 'make_bash_completion.py') copy(make_bash_completion_fp, self.temp_config_dir) make_optparse_fp = join(module_dir, 'make_optparse.py') copy(make_optparse_fp, self.temp_config_dir) with open(join(self.temp_config_dir, '__init__.py'), 'w') as f: f.write('') sys.path.append(self.temp_module_dir)
def test_get_cfg_module(self): self.assertEqual(_get_cfg_module('pyqi'), pyqi)
def test_get_cfg_module(self): self.assertEqual(_get_cfg_module('pyqi'), pyqi)