robotframework-testdoc 0.1.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of robotframework-testdoc might be problematic. Click here for more details.
- robotframework_testdoc-0.1.2.dist-info/METADATA +148 -0
- robotframework_testdoc-0.1.2.dist-info/RECORD +24 -0
- robotframework_testdoc-0.1.2.dist-info/WHEEL +5 -0
- robotframework_testdoc-0.1.2.dist-info/entry_points.txt +2 -0
- robotframework_testdoc-0.1.2.dist-info/licenses/LICENSE +201 -0
- robotframework_testdoc-0.1.2.dist-info/top_level.txt +1 -0
- testdoc/__init__.py +0 -0
- testdoc/__main__.py +3 -0
- testdoc/cli.py +91 -0
- testdoc/helper/cliargs.py +43 -0
- testdoc/helper/datetimeconverter.py +5 -0
- testdoc/helper/logger.py +9 -0
- testdoc/helper/pathconverter.py +50 -0
- testdoc/html/images/robotframework.svg +1 -0
- testdoc/html/templates/jinja_template_01.html +334 -0
- testdoc/html/themes/__init__.py +0 -0
- testdoc/html/themes/theme_config.py +27 -0
- testdoc/html/themes/themes.py +44 -0
- testdoc/html_rendering/render.py +31 -0
- testdoc/parser/modifier/sourceprefixmodifier.py +78 -0
- testdoc/parser/modifier/suitefilemodifier.py +115 -0
- testdoc/parser/testcaseparser.py +31 -0
- testdoc/parser/testsuiteparser.py +68 -0
- testdoc/testdoc.py +19 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from robot.api import SuiteVisitor, TestSuite
|
|
4
|
+
from .testcaseparser import TestCaseParser
|
|
5
|
+
|
|
6
|
+
class RobotSuiteParser(SuiteVisitor):
|
|
7
|
+
def __init__(self):
|
|
8
|
+
self.suites = []
|
|
9
|
+
self.tests = []
|
|
10
|
+
|
|
11
|
+
def visit_suite(self, suite):
|
|
12
|
+
|
|
13
|
+
# Skip suite if its already parsed into list
|
|
14
|
+
self._already_parsed(suite)
|
|
15
|
+
|
|
16
|
+
# Test Suite Parser
|
|
17
|
+
suite_info = {
|
|
18
|
+
"name": suite.name,
|
|
19
|
+
"doc": "<br>".join(line.replace("\\n","") for line in suite.doc.splitlines() if line.strip()) if suite.doc else None,
|
|
20
|
+
"is_folder": self._is_directory(suite),
|
|
21
|
+
"num_tests": len(suite.tests),
|
|
22
|
+
"source": str(suite.source),
|
|
23
|
+
"total_tests": 0,
|
|
24
|
+
"tests": [],
|
|
25
|
+
"sub_suites": [],
|
|
26
|
+
"metadata": None
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
# Parse Test Cases
|
|
30
|
+
suite_info = TestCaseParser().parse_test(suite, suite_info)
|
|
31
|
+
|
|
32
|
+
# Collect sub-suites recursive
|
|
33
|
+
suite_info, total_tests = self._recursive_sub_suite(suite, suite_info)
|
|
34
|
+
|
|
35
|
+
# Append to suites object
|
|
36
|
+
suite_info["total_tests"] = total_tests
|
|
37
|
+
self.suites.append(suite_info)
|
|
38
|
+
|
|
39
|
+
def parse_suite(self, suite_path):
|
|
40
|
+
suite = TestSuite.from_file_system(suite_path)
|
|
41
|
+
suite = TestCaseParser().consider_tags(suite)
|
|
42
|
+
suite.visit(self)
|
|
43
|
+
return self.suites
|
|
44
|
+
|
|
45
|
+
##############################################################################################
|
|
46
|
+
# Helper:
|
|
47
|
+
##############################################################################################
|
|
48
|
+
|
|
49
|
+
def _recursive_sub_suite(self,
|
|
50
|
+
suite: TestSuite,
|
|
51
|
+
suite_info: dict
|
|
52
|
+
):
|
|
53
|
+
total_tests = suite_info["num_tests"]
|
|
54
|
+
for sub_suite in suite.suites:
|
|
55
|
+
sub_parser = RobotSuiteParser()
|
|
56
|
+
sub_parser.visit_suite(sub_suite)
|
|
57
|
+
suite_info["sub_suites"].extend(sub_parser.suites)
|
|
58
|
+
total_tests += sum(s["total_tests"] for s in sub_parser.suites)
|
|
59
|
+
return suite_info, total_tests
|
|
60
|
+
|
|
61
|
+
def _is_directory(self, suite) -> bool:
|
|
62
|
+
suite_path = suite.source if suite.source else ""
|
|
63
|
+
return(os.path.isdir(suite_path) if suite_path else False)
|
|
64
|
+
|
|
65
|
+
def _already_parsed(self, suite):
|
|
66
|
+
existing_suite = next((s for s in self.suites if s["name"] == suite.name), None)
|
|
67
|
+
if existing_suite:
|
|
68
|
+
return
|
testdoc/testdoc.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from .helper.pathconverter import PathConverter
|
|
2
|
+
from .parser.testsuiteparser import RobotSuiteParser
|
|
3
|
+
from .html_rendering.render import TestDocHtmlRendering
|
|
4
|
+
from .parser.modifier.suitefilemodifier import SuiteFileModifier
|
|
5
|
+
|
|
6
|
+
class TestDoc():
|
|
7
|
+
|
|
8
|
+
def main(self):
|
|
9
|
+
# Convert to correct pathes
|
|
10
|
+
suite_path, output_path, config_path = PathConverter().path_convertion()
|
|
11
|
+
|
|
12
|
+
# Parse suite object & return complete suite object with all information
|
|
13
|
+
suite_object = RobotSuiteParser().parse_suite(suite_path)
|
|
14
|
+
|
|
15
|
+
# Run SuiteFileModifier to modify the test suite object
|
|
16
|
+
suite_object = SuiteFileModifier().run(suite_object)
|
|
17
|
+
|
|
18
|
+
# Render HTML file
|
|
19
|
+
TestDocHtmlRendering().render_testdoc(suite_object, output_path)
|