When Using subtest, all subtest captured output is written into the Parent Output Property

Open
#67 0 comments 0 reactions 1 assignee View on GitHub

@BethanyG is already working on this.

Since May 28, 2021.

Assessment

This issue has not been assessed yet.

Description

bug

If a user has used print() or other debugging methods in their code and the tests for that code are using unittest.subtest, the captured output for the subtests is being written into the parent output property in the results.json file -- one set of of output for each subtest. Not an ideal situation.

Steps to reproduce:

Using the tests/example-partial-failure-with-subtests/ test:

  1. Add print("User output is captured!") on line 8 of example_partial_failure_with_subtests.py
  2. Run ./bin/run.sh example-partial-failure-with-subtests
  3. Note that results.json has an entry that looks like this for ExampleSuccessTest.test_abc:
"name": "ExampleSuccessTest.test_abc",
      "status": "pass",
      "test_code": "input_data = ['frog', 'fish', 'coconut', 'pineapple', 'carrot', 'cucumber', 'grass', 'tree']\nresult_data = [(\"Hello, World!\", param) for param in input_data]\nnumber_of_variants = range(1, len(input_data) + 1)\n\nfor variant, param, result in zip(number_of_variants, input_data, result_data):\n    with self.subTest(f\"variation #{variant}\", param=param, result=result):\n        self.assertEqual(hello(param), result,",
      "task_id": 1,
      "output": "User output is captured!\nUser output is captured!\nUser output is captured!\nUser output is captured!\nUser output is captured!\nUser output is captured!\nUser output is captured!\nUser output is captured!"
    }

Ideally, we'd write captured output for a subtest into the output property for that subtest. In cases where there is not a subtest report (pytest only reports failed subtests), we would annotate the parent test output to indicate it came from a successful subtest.

Dominant language
Python
Stars
13
Forks
20
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from exercism/python-test-runner

All issues in exercism/python-test-runner

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.