import
os
import
time
def
findTestWithPath():
current_dir
=
os.getcwd()
folderName
=
os.listdir(current_dir)
TestSuit
=
[suite
for
suite
in
folderName
if
not
suite.find(
"TestSuit"
)]
testfile
=
[]
withPathFile
=
[]
for
suite
in
TestSuit:
testfile
=
testfile
+
os.listdir(
".\\"
+
suite)
for
withPath
in
testfile:
withPath
=
current_dir
+
"\\"+suite+"
\\"
+
withPath
withPathFile.append(withPath)
del
testfile
withPathFile
=
[name
for
name
in
withPathFile
if
not
"pyc"
in
name]
print
withPathFile
return
withPathFile
def
codeCoverage():
now
=
time.strftime(
"%Y%m%d%H%M"
)
htmlReport
=
os.getcwd()
+
"\\"+"
CoverageReport"
htmlCmd
=
"coverage html -d "
+
htmlReport
+
"\\"
+
now
for
pyfile
in
findTestWithPath():
runPyCmd
=
"coverage run "
+
pyfile
if
os.path.exists(htmlReport) :
os.system(runPyCmd)
os.system(htmlCmd)
else
:
os.mkdir(htmlReport)
os.system(runPyCmd)
os.system(htmlCmd)
if
__name__
=
=
"__main__"
:
codeCoverage()