Skip to content

Class converted to invalid code #51

@nedbat

Description

@nedbat

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})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions