Skip to content
Advertisement

How to pass a dict to a unit test using parameterized?

I have a list of dicts:

JavaScript

How do I pass the dict to a django unit test using parameterized? E.g.

JavaScript

Results in AttributeError: 'str' object has no attribute 'items' because the dict is being converted to a string.

Advertisement

Answer

As stated in the docs:

JavaScript

So I would try to convert MY_LIST to:

JavaScript

Which makes it a list of tuples that contain a single parameter to apply to the method you are testing.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement