Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrated tests failure output to CSV #3352

Merged
merged 3 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ openbb_terminal/portfolio/portfolios/*
*.http
.coverage.*
!openbb_terminal/reports/templates/*.ipynb
*_tests.csv

# pyinstaller artifacts
*.pyo
Expand Down
16 changes: 15 additions & 1 deletion openbb_terminal/terminal_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
import difflib
import logging
import os
import csv
from pathlib import Path
from datetime import datetime
import sys
import webbrowser
from typing import List

import dotenv
from rich import panel

Expand Down Expand Up @@ -1067,7 +1070,18 @@ def run_test_list(path_list: List[str], filtert: str, verbose: bool):
console.print("\n[red]Failures:[/red]\n")
for file, exception in fails.items():
logger.error("%s: %s failed", file, exception)
console.print(f"{file}: {exception}\n")
# Write results to CSV
timestamp = datetime.now().timestamp()
output_path = f"{timestamp}_tests.csv"
with open(output_path, "w") as file: # type: ignore
header = ["File", "Error"]
writer = csv.DictWriter(file, fieldnames=header) # type: ignore
writer.writeheader()
for file, exception in fails.items():
writer.writerow({"File": file, "Error": exception})

console.print(f"CSV of errors saved to {output_path}")

console.print(
f"Summary: [green]Successes: {SUCCESSES}[/green] [red]Failures: {FAILURES}[/red]"
)
Expand Down