Unittest BugFixes
This commit is contained in:
parent
ecec65be06
commit
8dfadea495
37
jsonlog.py
37
jsonlog.py
@ -7,7 +7,7 @@ import os
|
||||
import subprocess
|
||||
|
||||
import fstools
|
||||
from unittest.output import STATUS_AVAILABLE, STATUS_CHANGED, STATUS_CLEAN, STATUS_EXISTS, STATUS_IN_WORK, STATUS_MISSING, STATUS_OLD, STATUS_RELEASED, STATUS_UNKNOWN
|
||||
from unittest.output import STATUS_AVAILABLE, STATUS_CHANGED, STATUS_CLEAN, STATUS_EXISTS, STATUS_FAILED, STATUS_IN_WORK, STATUS_MISSING, STATUS_OLD, STATUS_RELEASED, STATUS_UNKNOWN
|
||||
|
||||
JSONLOG_FNAME = 'unittest.json'
|
||||
|
||||
@ -57,7 +57,7 @@ TOBI_DEPENDENCIES = "Dependencies"
|
||||
TOBI_DESCRIPTION = "Description"
|
||||
TOBI_NAME = "Name"
|
||||
TOBI_STATE = "State"
|
||||
TOBI_STATE_RELESED = 'Released'
|
||||
TOBI_STATE_RELEASED = 'Released'
|
||||
TOBI_STATE_IN_DEVELOPMENT = 'In development'
|
||||
TOBI_SUPP_INTERP = "Supported Interpreters"
|
||||
TOBI_VERSION = "Version"
|
||||
@ -123,11 +123,12 @@ def __get_release_state__(ut_folder, lib):
|
||||
return STATUS_MISSING
|
||||
else:
|
||||
ut_status = ut_data.get(MAIN_KEY_TESTOBJECT_INFO, {}).get(TOBI_STATE, 'unknown')
|
||||
if 'released' in ut_status.lower():
|
||||
if ut_status == TOBI_STATE_RELEASED:
|
||||
return STATUS_RELEASED
|
||||
elif 'work' in ut_status.lower():
|
||||
elif ut_status == TOBI_STATE_IN_DEVELOPMENT:
|
||||
return STATUS_IN_WORK
|
||||
else:
|
||||
print(ut_status)
|
||||
return STATUS_UNKNOWN
|
||||
|
||||
|
||||
@ -155,7 +156,7 @@ def __get_testcase_integrity__(ut_folder, lib):
|
||||
if tc_version == current_version:
|
||||
return STATUS_CLEAN
|
||||
else:
|
||||
return STATUS_CHANGED
|
||||
return STATUS_IN_WORK
|
||||
|
||||
|
||||
def get_lib_testcase_integrity(ut_folder):
|
||||
@ -193,28 +194,12 @@ def get_ut_src_integrity(ut_folder):
|
||||
return __get_src_integrity__(ut_folder, False)
|
||||
|
||||
|
||||
def status_module(ut_folder):
|
||||
try:
|
||||
with open(get_lib_jsonlog(ut_folder), 'r') as fh:
|
||||
ut_lib = json.loads(fh.read())
|
||||
except IOError:
|
||||
def status_lib_unittest(ut_folder):
|
||||
if get_lib_release_state(ut_folder) == STATUS_RELEASED and get_lib_src_integrity(ut_folder) == STATUS_CLEAN and get_lib_testcase_integrity(ut_folder) == STATUS_CLEAN:
|
||||
return STATUS_CLEAN
|
||||
elif get_lib_release_state(ut_folder) == STATUS_MISSING and get_lib_src_integrity(ut_folder) == STATUS_MISSING and get_lib_testcase_integrity(ut_folder) == STATUS_MISSING:
|
||||
return STATUS_MISSING
|
||||
else:
|
||||
try:
|
||||
with open(get_ut_jsonlog(ut_folder), 'r') as fh:
|
||||
ut_ut = json.loads(fh.read())
|
||||
except IOError:
|
||||
return STATUS_UNKNOWN
|
||||
else:
|
||||
tested_version = ut_lib.get(MAIN_KEY_TESTOBJECT_INFO, {}).get(TOBI_VERSION)
|
||||
current_version = module_uid(get_lib_folder(ut_folder))
|
||||
if ut_ut[MAIN_KEY_TESTOBJECT_INFO] != ut_lib[MAIN_KEY_TESTOBJECT_INFO] or ut_ut[MAIN_KEY_UNITTEST_INFO] != ut_lib[MAIN_KEY_UNITTEST_INFO] or tested_version != current_version:
|
||||
return STATUS_OLD
|
||||
else:
|
||||
ut_status = ut_lib.get(MAIN_KEY_TESTOBJECT_INFO, {}).get(TOBI_STATE, 'unknown')
|
||||
if 'released' in ut_status.lower():
|
||||
return STATUS_RELEASED
|
||||
elif 'work' in ut_status.lower():
|
||||
elif get_lib_release_state(ut_folder) == STATUS_IN_WORK or get_lib_src_integrity(ut_folder) == STATUS_IN_WORK or get_lib_testcase_integrity(ut_folder) == STATUS_IN_WORK:
|
||||
return STATUS_IN_WORK
|
||||
else:
|
||||
return STATUS_UNKNOWN
|
||||
|
@ -7,7 +7,7 @@ import os
|
||||
from unittest.output import termcolors, coverage_output
|
||||
|
||||
from unittest.output import STATUS_COLORS, STATUS_UNKNOWN
|
||||
from unittest.jsonlog import lib_coverage, status_doc, status_git, status_module, status_spec, versions_module
|
||||
from unittest.jsonlog import lib_coverage, status_doc, status_git, status_lib_unittest, status_spec, versions_module
|
||||
|
||||
STATUS_LENGTH = 13
|
||||
|
||||
@ -37,7 +37,7 @@ def module_status_head():
|
||||
def module_status_line(ut_folder):
|
||||
rv = '%25s%s%s%s%s%s%s\n' % (
|
||||
os.path.basename(ut_folder) + ':',
|
||||
status_output(status_module(ut_folder)),
|
||||
status_output(status_lib_unittest(ut_folder)),
|
||||
status_output(status_doc(ut_folder)),
|
||||
status_output(versions_module(ut_folder), termcolors.BOLD),
|
||||
coverage_output(*lib_coverage(ut_folder), length=STATUS_LENGTH),
|
||||
|
2
run.py
2
run.py
@ -225,7 +225,7 @@ def unittest_prepare(ut_folder):
|
||||
testobject_info[jsonlog.TOBI_VERSION] = jsonlog.module_uid(config.lib.__path__[0])
|
||||
testobject_info[jsonlog.TOBI_DESCRIPTION] = config.lib.__DESCRIPTION__
|
||||
testobject_info[jsonlog.TOBI_SUPP_INTERP] = ', '.join(['python%d' % vers for vers in config.lib.__INTERPRETER__])
|
||||
testobject_info[jsonlog.TOBI_STATE] = jsonlog.TOBI_STATE_RELESED if config.release_unittest_version == unittest_info[jsonlog.UTEI_VERSION] else jsonlog.TOBI_STATE_IN_DEVELOPMENT
|
||||
testobject_info[jsonlog.TOBI_STATE] = jsonlog.TOBI_STATE_RELEASED if config.release_unittest_version == unittest_info[jsonlog.UTEI_VERSION] else jsonlog.TOBI_STATE_IN_DEVELOPMENT
|
||||
testobject_info[jsonlog.TOBI_DEPENDENCIES] = []
|
||||
for dependency in config.lib.__DEPENDENCIES__:
|
||||
testobject_info[jsonlog.TOBI_DEPENDENCIES].append((dependency, jsonlog.module_uid(os.path.join(jsonlog.get_ut_src_folder(ut_folder), dependency))))
|
||||
|
Loading…
x
Reference in New Issue
Block a user