def get_or_ask_for_source_location(source_name): """Returns the location of the source directory.""" source_env = '%s_SRC' % source_name.upper() if os.environ.get(source_env): source_directory = os.environ.get(source_env) else: message = ('This is a %(name)s testcase, please define %(env_name)s' ' or enter your %(name)s source location here' % {'name': source_name, 'env_name': source_env}) source_directory = common.get_valid_abs_dir( common.ask( message, 'Please enter a valid directory', common.get_valid_abs_dir)) check_gclient_managed(source_directory) return source_directory
def test_empty(self): """Test empty.""" self.assertIsNone(common.get_valid_abs_dir(''))
def test_validity(self): """Test a valid dir.""" os.makedirs('/test/test2') self.assertEqual('/test/test2', common.get_valid_abs_dir('/test/test2')) self.assertIsNone(common.get_valid_abs_dir('/test/test3'))