Skip to content

Commit

Permalink
add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
caioariede committed Sep 17, 2024
1 parent 218093b commit 2d51ebc
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/pytest_xflaky/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ def __init__(self, config):
if self.config.option.xflaky_report:
self.generate_report()

report_file = self.config.option.json_report_file
directory = self.config.option.xflaky_reports_directory
self.new_report_file = f"{uuid.uuid4()}-{os.path.basename(report_file)}"

def check_jsonreport(self):
if not self.config.pluginmanager.hasplugin("pytest_jsonreport"):
jsonreport_pytest_configure(self.config)
Expand All @@ -58,9 +62,7 @@ def make_reports_dir(self):
@pytest.hookimpl(trylast=True)
def pytest_sessionfinish(self, session):
report_file = self.config.option.json_report_file
directory = self.config.option.xflaky_reports_directory
name = f"{uuid.uuid4()}-{os.path.basename(report_file)}"
shutil.copy(report_file, f"{directory}/{name}")
shutil.copy(report_file, self.new_report_file)

def generate_report(self):
finder = FlakyTestFinder(
Expand All @@ -81,6 +83,10 @@ def print_report(self, flaky_tests):
f"Flaky test found: {flaky_test.test} (ok: {flaky_test.ok}, failed: {flaky_test.failed}"
)

def pytest_terminal_summary(self, terminalreporter):
terminalreporter.write_sep("-", "XFLAKY report")
terminalreporter.write_line(f"Report file copied to {self.new_report_file}")


class FlakyTestFinder:
def __init__(self, *, directory: str, min_failures: int):
Expand Down

0 comments on commit 2d51ebc

Please sign in to comment.