pytest-dev / unittest2pytest

helps rewriting Python `unittest` test-cases into `pytest` test-cases
GNU General Public License v3.0
128 stars 27 forks source link

doesn't handle self.assertDictContainsSubset #22

Closed rtdean closed 7 years ago

rtdean commented 7 years ago

If you have a unittest that contains an assertDictContainsSubset, unittest2pytest will happily ignore/skip over it.

class ExampleTest(unittest.TestCase):
    def test_dict_subset():
        subset = {'a': 1}
        superset = {'a': 1, 'b': 2}
        self.assertDictContainsSubset(subset, superset)

This can be replaced with the following:

def test_dict_subset():
    subset = {'a': 1}
    superset = {'a': 1, 'b': 2}
    assert dict(superset, **subset) == superset
htgoebel commented 7 years ago

Thanks for sharing this idea! Looks easy to implement.

RonnyPfannschmidt commented 7 years ago

@htgoebel as far as i can tell the checked in test reverses the order

htgoebel commented 7 years ago

Oh, thanks for pointing to this. I implemented it the wrong way round by accident. Fixed in 758fa33.