Skip to content

Commit 78ec66e

Browse files
authored
Improve reporters and models (#30)
* for reporter_web: - allow port definition - improve logging and status - add ReportManager into TestDetails - new TestStep class * move models to models folder
1 parent 89e04e0 commit 78ec66e

30 files changed

+205
-103
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@
6666
* **log:** shows test execution on .log file, with the same name as the project_name, errors are shown in stderr
6767
* **portalio:** ReportPortalIO Web REST DB and reporter:
6868
* **slack:** tests results are sent to Slack channel
69-
* **web:** tests results can be seen in realtime on a browser
69+
* **web:** tests results can be seen in realtime on a browser. use **-r-web-port PORT** to specify other than 9204
7070
* **xml:** test results will be saved on report.xml file
7171

7272

7373
# 2.3. Run:
7474
- ### options:
75-
* **-rid** RunID (ex: -rid 17, if not passed than current hour and minute will be used ex: 2359)
75+
* **-rid** RunID (ex: -rid 17, if not passed then current hour and minute will be used ex: 2359)
7676
* **-pn** ProjectName (ex: -pn jules)
7777
* **-env** EnvironmentName to test (ex: -env dev)
7878
* **-rf** ResultsFolder (ex: -rf "/qa/test_results/"), where the tests results will be stored

testipy/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
#!/usr/bin/env python3
2-
31
import logging
42

53

6-
__version__ = "0.10.1"
4+
__version__ = "0.10.2"
75
__app__ = "TestiPy"
86
__app_full__ = "Python Test Tool"
97
__author__ = "Pedro Nunes"

testipy/configs/default_config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22

3-
from testipy.configs import enums_data
3+
from testipy.configs.enums_data import STATE_PASSED, STATE_FAILED
44

55
# run.py
66
default_project_name = "local"
@@ -24,8 +24,8 @@
2424
separator_and_join_tags = "&"
2525

2626
# execute_tests.py
27-
if_no_test_started_mark_as = enums_data.STATE_PASSED
28-
count_as_failed_states = [enums_data.STATE_FAILED]
27+
if_no_test_started_mark_as = STATE_PASSED
28+
count_as_failed_states = [STATE_FAILED]
2929
suite_threads = 1
3030

3131
# report_base.py

testipy/engine/execute_tests.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1+
from __future__ import annotations
12
import os
23
import traceback
34
import concurrent.futures
45

5-
from typing import List
6+
from typing import List, TYPE_CHECKING
67

78
from testipy import get_exec_logger
89
from testipy.configs import enums_data, default_config
9-
from testipy.engine.models import PackageAttr, SuiteAttr, TestMethodAttr
1010
from testipy.lib_modules import common_methods as cm
1111
from testipy.lib_modules.common_methods import synchronized
1212
from testipy.lib_modules.state_counter import StateCounter
1313
from testipy.lib_modules.textdecor import color_state
1414
from testipy.lib_modules.start_arguments import StartArguments
1515
from testipy.helpers.prettify import format_duration
1616
from testipy.helpers.handle_assertions import ExpectedError
17-
from testipy.reporter.report_manager import ReportManager
18-
from testipy.reporter import SuiteDetails, TestDetails
17+
18+
if TYPE_CHECKING:
19+
from testipy.models import PackageAttr, SuiteAttr, TestMethodAttr, SuiteDetails, TestDetails
20+
from testipy.reporter.report_manager import ReportManager
21+
1922

2023
_exec_logger = get_exec_logger()
2124

testipy/engine/read_tests.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
from testipy.lib_modules import py_inspector, common_methods as cm
1010
from testipy.lib_modules.args_parser import ArgsParser
1111
from testipy.helpers import load_config
12-
from testipy.engine.models import (
13-
PackageAttr, SuiteAttr, TestMethodAttr,
12+
from testipy.models.attr import (
13+
PackageAttr,
14+
SuiteAttr,
15+
TestMethodAttr,
1416
get_package_by_name,
1517
mark_packages_suites_methods_ids,
1618
show_test_structure,

testipy/helpers/data_driven_testing.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
from __future__ import annotations
2-
32
from abc import abstractmethod, ABC
43
from collections import OrderedDict
54
from enum import Enum
6-
from typing import Union, Dict, List, Tuple
5+
from typing import Union, Dict, List, Tuple, TYPE_CHECKING
76

87
from testipy.configs import enums_data
9-
from testipy.reporter.package_manager import SuiteDetails, TestDetails
10-
from testipy.reporter.report_manager import ReportManager
118
from testipy.helpers import get_traceback_tabulate, load_config, left_update_dict, prettify
129
from testipy.helpers.handle_assertions import ExpectedError, SkipTestError
1310

11+
if TYPE_CHECKING:
12+
from testipy.models import SuiteDetails, TestDetails
13+
from testipy.reporter import ReportManager
14+
1415

1516
class RunMode(Enum):
1617
SCENARIOS_AS_TESTS__USECASES_AS_TESTSTEPS = 1

testipy/helpers/errors.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,15 @@ def get_traceback_list(exc_value: BaseException) -> List[Dict]:
4242
tbe = traceback.TracebackException.from_exception(exc_value)
4343

4444
# get stacktrace (cascade methods calls)
45-
error_lines = [{
45+
error_lines = [
46+
{
4647
"filename": frame_summary.filename,
4748
"method" : frame_summary.name,
4849
"lineno" : frame_summary.lineno,
4950
"code" : frame_summary.line
50-
} for frame_summary in tbe.stack]
51+
}
52+
for frame_summary in tbe.stack
53+
]
5154

5255
# append error, by order of execution
5356
result.append({

testipy/helpers/handle_assertions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ def assert_equal_complex_object(
8787

8888

8989
def assert_equal_dicts(
90-
expected: Any,
91-
received: Any,
90+
expected: Dict,
91+
received: Dict,
9292
expected_name: str = "expected",
9393
received_name: str = "received",
9494
) -> None:
@@ -103,8 +103,8 @@ def assert_equal_dicts(
103103

104104

105105
def assert_equal_lists(
106-
expected: Any,
107-
received: Any,
106+
expected: List,
107+
received: List,
108108
expected_name: str = "expected",
109109
received_name: str = "received",
110110
same_len: bool = True,

testipy/lib_modules/args_parser.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/usr/bin/env python3
21
from __future__ import annotations
32

43
import sys

testipy/lib_modules/browser_manager/playwright.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/usr/bin/env python3
21
import base64
32

43
from time import sleep

0 commit comments

Comments
 (0)