Skip to content

Commit 67ffb57

Browse files
authored
Release v0_10_4 (#34)
* add reporter_html.py
1 parent a5b4a2b commit 67ffb57

12 files changed

Lines changed: 802 additions & 141 deletions

testipy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22

33

4-
__version__ = "0.10.3"
4+
__version__ = "0.10.4"
55
__app__ = "TestiPy"
66
__app_full__ = "Python Test Tool"
77
__author__ = "Pedro Nunes"

testipy/reporter/reporters/df_manager.py

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
pd.options.display.width = 220
99

1010

11-
def _get_state_dummies(df, columns=("Package", "Suite", "Test", "Level")):
11+
def get_state_dummies(df, columns=("Package", "Suite", "Test", "Level")):
1212
df_dummies = df.copy()
1313

1414
# get dummies for States
@@ -22,11 +22,21 @@ def _get_state_dummies(df, columns=("Package", "Suite", "Test", "Level")):
2222
dict_states[state] = "sum"
2323

2424
# aggregate mode
25-
aggregate = {"T#": "size", "Steps": "sum", "Duration": "sum", "Start time": "min", "End time": "max"} # , "Reason": "unique"
25+
aggregate = {
26+
"T#": "size",
27+
"Steps": "sum",
28+
"Duration": "sum",
29+
"Start time": "min",
30+
"End time": "max",
31+
} # , "Reason": "unique"
2632
aggregate.update(dict_states)
2733

2834
# group by tests
29-
df_dummies = df_dummies.groupby(columns).agg(aggregate).rename(columns={"T#": "Total"}, inplace=False)
35+
df_dummies = (
36+
df_dummies.groupby(columns)
37+
.agg(aggregate)
38+
.rename(columns={"T#": "Total"}, inplace=False)
39+
)
3040

3141
# calc Passed percentage
3242
df_dummies["%PASS"] = df_dummies[enums_data.STATE_PASSED] / df_dummies["Total"]
@@ -44,7 +54,19 @@ def _get_state_summary(df, columns=("Package", "Suite", "Test", "Level", "State"
4454
df_ss = df.copy()
4555

4656
# group by Reason of State
47-
df_ss = df_ss.groupby(columns).agg({"T#": "size", "Steps": "sum", "Duration": "sum", "Start time": "min", "End time": "max"}).rename(columns={"T#": "Total"}, inplace=False)
57+
df_ss = (
58+
df_ss.groupby(columns)
59+
.agg(
60+
{
61+
"T#": "size",
62+
"Steps": "sum",
63+
"Duration": "sum",
64+
"Start time": "min",
65+
"End time": "max",
66+
}
67+
)
68+
.rename(columns={"T#": "Total"}, inplace=False)
69+
)
4870

4971
# calc percentage of each row
5072
df_ss["%"] = df_ss["Total"] / df_ss["Total"].sum()
@@ -58,30 +80,32 @@ def _get_state_summary(df, columns=("Package", "Suite", "Test", "Level", "State"
5880

5981

6082
def reduce_datetime(df, endwith=":%S"):
61-
for column in df.select_dtypes(include='datetime64').columns:
83+
for column in df.select_dtypes(include="datetime64").columns:
6284
df[column] = df[column].dt.strftime(f"%Y-%m-%d %H:%M{endwith}")
6385
return df
6486

6587

6688
# -----------------------------------------------------------------------------------------------------
6789
"""
6890
Total Duration Start time End time PASSED FAILED SKIPPED %PASSED
69-
Package Suite Test
91+
Package Suite Test
7092
demo suite_demo_01 test_01_show_internal_counters 2 0.20 2020-02-05 14:51:34 2020-02-05 14:51:34 2 0 0 100.00
7193
test_02_division_by_zero 2 0.00 2020-02-05 14:51:34 2020-02-05 14:51:34 1 1 0 50.00
7294
"""
7395

7496

7597
def get_test_dummies(df):
76-
return _get_state_dummies(df, columns=["Package", "Suite", "Test", "Level"]) #, "TAGs"
98+
return get_state_dummies(
99+
df, columns=["Package", "Suite", "Test", "Level"]
100+
) # , "TAGs"
77101

78102

79103
def get_suite_dummies(df):
80-
return _get_state_dummies(df, columns=["Package", "Suite", "Level"])
104+
return get_state_dummies(df, columns=["Package", "Suite", "Level"])
81105

82106

83107
def get_package_dummies(df):
84-
return _get_state_dummies(df, columns=["Package", "Level"])
108+
return get_state_dummies(df, columns=["Package", "Level"])
85109

86110

87111
# -----------------------------------------------------------------------------------------------------
@@ -95,13 +119,15 @@ def get_package_dummies(df):
95119

96120

97121
def get_test_ros_summary(df):
98-
return _get_state_summary(df, ["Package", "Suite", "Test", "Prio", "Level", "State", "Usecase", "Reason"])
122+
return _get_state_summary(
123+
df, ["Package", "Suite", "Test", "Prio", "Level", "State", "Usecase", "Reason"]
124+
)
99125

100126

101127
# -----------------------------------------------------------------------------------------------------
102128
"""
103129
Total Duration Start time End time
104-
Package Suite State
130+
Package Suite State
105131
demo suite_demo_01 FAILED 2 0.901410 2020-02-05 14:14:22 2020-02-05 14:14:23
106132
PASSED 7 0.202453 2020-02-05 14:14:22 2020-02-05 14:14:23
107133
"""
@@ -122,4 +148,5 @@ def get_levels_state_summary(df):
122148
def get_state_summary(df):
123149
return _get_state_summary(df, ["State"])
124150

151+
125152
# -----------------------------------------------------------------------------------------------------

testipy/reporter/reporters/reporter_echo.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
from testipy.configs import enums_data
66
from testipy.helpers import format_duration, prettify
77
from testipy.lib_modules import textdecor
8-
from testipy.lib_modules.start_arguments import StartArguments
98
from testipy.reporter import ReportInterface
109
from testipy.reporter.reporters import df_manager as dfm
1110

1211
if TYPE_CHECKING:
1312
from testipy.models import PackageAttr, PackageDetails, SuiteDetails, TestDetails
1413
from testipy.reporter import ReportManager
14+
from testipy.lib_modules.start_arguments import StartArguments
1515

1616

1717
_line_size = 160
@@ -37,10 +37,10 @@ def copy_file(self, current_test: TestDetails, orig_filename: str, dest_filename
3737

3838
def _startup_(self, selected_tests: List[PackageAttr]):
3939
_selected_tests = self.rm.get_selected_tests_as_dict()
40-
print("\n"*2)
41-
print("#"*_line_size)
40+
print("\n" * 2)
41+
print("#" * _line_size)
4242
print(" Selected tests to run ".center(_line_size, "#"))
43-
print("#"*_line_size)
43+
print("#" * _line_size)
4444
print(tabulate(_selected_tests["data"], headers=_selected_tests["headers"], tablefmt="simple"))
4545
print("\n"*2)
4646

@@ -55,10 +55,10 @@ def _teardown_(self, end_state: str):
5555
summary = f"{self.rm.pm.state_counter.get_state_percentage(enums_data.STATE_PASSED):.2f}% [{self.rm.pm.state_counter}] took {format_duration(self.rm.pm.get_duration())}"
5656

5757
# show results
58-
print("\n"*6)
59-
print("#"*_line_size)
58+
print("\n" * 6)
59+
print("#" * _line_size)
6060
print(f" Teardown {summary} ".center(_line_size, "#"))
61-
print("#"*_line_size)
61+
print("#" * _line_size)
6262

6363
# show resume tables
6464
print("")
@@ -82,8 +82,8 @@ def end_suite(self, sd: SuiteDetails):
8282
pass
8383

8484
def start_test(self, current_test: TestDetails):
85-
print("\n"*5)
86-
print("-"*_line_size)
85+
print("\n" * 5)
86+
print("-" * _line_size)
8787
print(f"> Starting test: {current_test} <".center(_line_size, "-"))
8888

8989
def test_info(self, current_test: TestDetails, info: str, level: str, attachment: Dict=None):

testipy/reporter/reporters/reporter_excel.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
import pandas as pd
55

66
from testipy import get_exec_logger
7-
from testipy.lib_modules.start_arguments import StartArguments
87
from testipy.reporter import ReportInterface
98
from testipy.reporter.reporters import df_manager as dfm
109

1110
if TYPE_CHECKING:
1211
from testipy.models import PackageAttr, PackageDetails, SuiteDetails, TestDetails
1312
from testipy.reporter import ReportManager
13+
from testipy.lib_modules.start_arguments import StartArguments
1414

1515

1616
_exec_logger = get_exec_logger()
@@ -28,10 +28,10 @@ def __init__(self, rm: ReportManager, sa: StartArguments):
2828
self.__ensure_folder(sa.full_path_results_folder_runtime)
2929

3030
# full path name
31-
self._fpn = os.path.join(sa.full_path_results_folder_runtime, f"report.xlsx")
31+
self._fpn = os.path.join(sa.full_path_results_folder_runtime, "report.xlsx")
3232

3333
# create Excel Writer
34-
self.writer = pd.ExcelWriter(self._fpn, engine='xlsxwriter', datetime_format='yyyy-mm-dd hh:mm:ss.000')
34+
self.writer = pd.ExcelWriter(self._fpn, engine="xlsxwriter", datetime_format="yyyy-mm-dd hh:mm:ss.000")
3535

3636
# DataFrame for testStepCounters
3737
self._df_step_counters = pd.DataFrame(columns=self._columns)
@@ -61,8 +61,8 @@ def _create_summarys(self, df):
6161

6262
# format cells
6363
fmt = self.writer.book.add_format({"font_name": "Calibri", "font_size": 9})
64-
for (name, sheet) in self.writer.sheets.items():
65-
sheet.set_column('A:Z', None, fmt)
64+
for name, sheet in self.writer.sheets.items():
65+
sheet.set_column("A:Z", None, fmt)
6666

6767
# save file
6868
self.writer.close()
@@ -98,14 +98,16 @@ def start_test(self, current_test: TestDetails):
9898
def test_info(self, current_test: TestDetails, info, level, attachment=None):
9999
pass
100100

101-
def test_step(self,
102-
current_test: TestDetails,
103-
state: str,
104-
reason_of_state: str = "",
105-
description: str = "",
106-
take_screenshot: bool = False,
107-
qty: int = 1,
108-
exc_value: BaseException = None):
101+
def test_step(
102+
self,
103+
current_test: TestDetails,
104+
state: str,
105+
reason_of_state: str = "",
106+
description: str = "",
107+
take_screenshot: bool = False,
108+
qty: int = 1,
109+
exc_value: BaseException = None,
110+
):
109111
pass
110112

111113
# this will serve the purpose only for testSteps, because for tests is done on teardown

0 commit comments

Comments
 (0)