Skip to content

Commit 3a2bb9f

Browse files
committed
add inspect to pull func name
1 parent 85ff014 commit 3a2bb9f

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

aci-preupgrade-validation-script.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from getpass import getpass
2323
from collections import defaultdict
2424
from datetime import datetime
25+
import inspect
2526
import warnings
2627
import time
2728
import pexpect
@@ -65,7 +66,8 @@
6566

6667

6768
class syntheticMaintPValidate:
68-
def __init__(self, name, description):
69+
def __init__(self, func, name, description):
70+
self.function_name = func
6971
self.name = name
7072
self.description = description
7173
self.reason = ""
@@ -118,7 +120,7 @@ def writeResult(self):
118120
Write the results of the syntheticMaintPValidate object to a file.
119121
:return: None
120122
"""
121-
filename = self.name + '.json'
123+
filename = self.function_name + '.json'
122124
path = "cx-preupgrade-validation-results"
123125
if not os.path.isdir(path):
124126
os.mkdir(path)
@@ -1094,8 +1096,9 @@ def print_result(title, result, msg='',
10941096
unformatted_headers=None, unformatted_data=None,
10951097
recommended_action='',
10961098
doc_url='',
1097-
adjust_title=False):
1098-
synth = syntheticMaintPValidate(title, "")
1099+
adjust_title=False,
1100+
func="test"):
1101+
synth = syntheticMaintPValidate(func, title, "")
10991102
if result in [FAIL_O, FAIL_UF, ERROR, MANUAL, POST]:
11001103
# TODO: deal with unformatted data and headers
11011104
synth.updateFailureDetails(
@@ -4687,7 +4690,7 @@ def fc_ex_model_check(index, total_checks, tversion, **kwargs):
46874690
if data:
46884691
result = FAIL_O
46894692

4690-
print_result(title, result, msg, headers, data, recommended_action=recommended_action, doc_url=doc_url)
4693+
print_result(title, result, msg, headers, data, recommended_action=recommended_action, doc_url=doc_url, func=inspect.currentframe().f_code.co_name)
46914694
return result
46924695

46934696

0 commit comments

Comments
 (0)