-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TestCaseParser module to DocGenerator
- Loading branch information
palaciosjeremias
committed
Jul 28, 2021
1 parent
8a2eaf9
commit fc20b17
Showing
2 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import pytest | ||
|
||
class PytestPlugin: | ||
def __init__(self): | ||
self.collected = [] | ||
|
||
def pytest_collection_modifyitems(self, items): | ||
for item in items: | ||
self.collected.append(item.nodeid) | ||
|
||
class TestCaseParser: | ||
def __init__(self): | ||
self.plugin = PytestPlugin() | ||
|
||
def collect(self, path): | ||
pytest.main(['--collect-only', path], plugins=[self.plugin]) | ||
output = {} | ||
for item in self.plugin.collected: | ||
tmp = item.split("::") | ||
file = tmp[0] | ||
tmp = tmp[1].split("[") | ||
test = tmp[0] | ||
if not test in output: | ||
output[test] = [] | ||
if len(tmp) >= 2: | ||
tmp = tmp[1].split("]") | ||
test_case = tmp[0] | ||
output[test].append(test_case) | ||
return output | ||
|
||
|
||
test = TestCaseParser() | ||
test.collect("../../tests/integration/test_wazuh_db/test_wazuh_db.py") |