本文整理匯總了Python中chiptools.core.project.Project.get_tests方法的典型用法代碼示例。如果您正苦於以下問題:Python Project.get_tests方法的具體用法?Python Project.get_tests怎麽用?Python Project.get_tests使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類chiptools.core.project.Project
的用法示例。
在下文中一共展示了Project.get_tests方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: CommandLine
# 需要導入模塊: from chiptools.core.project import Project [as 別名]
# 或者: from chiptools.core.project.Project import get_tests [as 別名]
class CommandLine(cmd.Cmd):
def __init__(self, project=None):
super(CommandLine, self).__init__()
prj = ''
if project is None:
try:
self.project = Project()
projects = self.locateProjects()
if len(projects) > 0:
prj = (
'Type ' + term.colourise(
'\'load_project <path>\'', fg='yellow'
) +
' to load a project.\n'
)
prj += (
'The current directory contains ' +
'the following projects:\n'
)
prj += term.colourise(
'\n'.join('\t{0}: {1}'.format(
idx+1,
path
) for idx, path in enumerate(projects)),
fg='yellow'
)
self.intro = INTRO_TEMPL % dict(
version=_version.__version__,
projects=prj,
)
except exceptions.ProjectFileException:
log.error(
'The project file contains errors, ' +
'fix them and then type \'reload\''
)
except:
log.error(
'The software has to terminate due to the following error:'
)
log.error(traceback.format_exc())
sys.exit(1)
else:
self.project = project
prj = (
'Project contains ' + term.colourise(
str(len(self.project.get_files())),
fg='yellow'
) + ' file(s) and ' + term.colourise(
str(len(self.project.get_tests())),
fg='yellow'
) + ' test(s).'
)
self.intro = INTRO_TEMPL % dict(
version=_version.__version__,
projects=prj,
)
self.test_set = set()
def locateProjects(self):
"""
Return a list of projects found in the current path.
"""
projects = []
logging.getLogger("chiptools").setLevel(
logging.CRITICAL
)
for filePath in os.listdir(os.getcwd()):
if filePath.endswith('.xml'):
try:
tempProject = Project()
# Load the XML file
XmlProjectParser.load_project(filePath, tempProject)
# If the project contains files we can add it to our list
files = tempProject.get_files()
files = files if files is not None else []
if len(files) != 0:
projects.append(filePath)
except:
pass
logging.getLogger("chiptools").setLevel(logging.INFO)
return projects
@wraps_do_commands
def do_load_project(self, path):
"""Load the given project XML file: load_project <path_to_project>"""
path = os.path.abspath(path)
if os.path.exists(path) and os.path.isfile(path):
try:
log.info(
'Loading {0} in current working directory: {1}'.format(
path,
os.getcwd()
)
)
XmlProjectParser.load_project(path, self.project)
except:
log.error('The project could not be loaded due to an error:')
log.error(traceback.format_exc())
else:
#.........這裏部分代碼省略.........