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

Error in report creation #44

Open
Rdvp1514 opened this issue Jun 28, 2023 · 1 comment
Open

Error in report creation #44

Rdvp1514 opened this issue Jun 28, 2023 · 1 comment

Comments

@Rdvp1514
Copy link

Rdvp1514 commented Jun 28, 2023

  1. Python version python --version----V3.10
  2. Test Junkie version pip show test_junkie -----Version: 0.8a6
  3. Platform aka Windows 10 or Linux Mint 18.1 ---Linux
  4. Command used, if running via terminal ---python3 Runner.py
  5. Smallest code snippet that can reproduce the issue and /or description of the issue
    .local/lib/python3.10/site-packages/test_junkie/metrics.py", line 179, in get_basic_report
    report["tests"][param_data["status"]] += 1
    KeyError: None

Expected behavior

The code shoud returne the report

Actual behavior

KeyError: None


PATH: venv/lib/python3.10/site-packages/test_junkie/metrics.py line 156
There is the code to fix the error

`

from collections import defaultdict

def get_basic_report(self):
def get_template():
return {"total": 0,
TestCategory.SUCCESS: 0,
TestCategory.FAIL: 0,
TestCategory.ERROR: 0,
TestCategory.IGNORE: 0,
TestCategory.SKIP: 0,
TestCategory.CANCEL: 0}

report = {"tests": get_template(),
          "suites": defaultdict(get_template)}

for suite in self.__executed_suites:
    for test in suite.get_test_objects():
        test_metrics = test.metrics.get_metrics()
        for class_param, class_param_data in test_metrics.items():
            for param, param_data in class_param_data.items():
                report["tests"]["total"] += 1
                if param_data["status"] is not None:
                    report["tests"][param_data["status"]] += 1
                    report["suites"][suite]["total"] += 1
                    report["suites"][suite][param_data["status"]] += 1

return report

`

@ArturSpirin
Copy link
Owner

@Rdvp1514 I just looked at the code. Looks like you are getting a None value from param_data["status"], which should not be None. So the issue is somewhere else, not in the get_basic_report function. It would be helpful if you can provide the code that you run to repro this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants