pytest-dev / pytest-dev/unittest2pytest
Class converted to invalid code
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 141
- Forks
- 28
- PR merge metrics
- No merged PRs in 30d
Description
One of my test files (https://github.com/nedbat/coveragepy/blob/coverage-5.4/tests/test_testing.py) was converted into invalid code. I don't know what it is about that file that caused it, though it is a bit twisty: it's a test of test assert helper methods.
Here is a stripped-down file that shows the same behavior:
import pytest
from coverage.backunittest import TestCase
class TestingTest(TestCase):
"""Tests of helper methods on `backunittest.TestCase`."""
def test_assert_count_equal(self):
self.assertCountEqual(set(), set())
with self.assertRaises(AssertionError):
self.assertCountEqual({1,2,3}, set())
with self.assertRaises(AssertionError):
self.assertCountEqual({1,2,3}, {4,5,6})
Running unittest2pytest -w test_testing.py, the file becomes:
import pytest
from coverage.backunittest import TestCase
"""Tests of helper methods on `backunittest.TestCase`."""
deftest_assert_count_equal(self):
self.assertCountEqual(set(), set())
with pytest.raises(AssertionError):
self.assertCountEqual({1,2,3}, set())
withpytest.raises(AssertionError):
self.assertCountEqual({1,2,3}, {4,5,6})
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running unittest2pytest -w test_testing.py against the reduced example and inspect the conversion path that handles TestCase classes and nested assertRaises blocks. Use tests/test_testing.py and the shown before-and-after output as the regression case; done means the converted file remains valid Python with the class, method, and nested context managers preserved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100