New issue 638: python.py:813 (in "parametrize") raises "TypeError: object of type 'int' has no len()" in some cases https://bitbucket.org/hpk42/pytest/issue/638/pythonpy-813-in-parametrize-raises
Eric Dand: Passing a one-element array for `argnames` and an array of `int`s as `argvalues` to `parametrize` causes the `assert` at line 813 to fail. This is only caused by this edge case: - If `argnames` is a single-element string (ie. no commas, not enclosed in an array), 788-791 will try to split argnames by commas, find at 790 that `len(argnames) == 1`, and will box up `argvalues`'s values into tuples. - If `argnames` is an array that has more than one element, each element of `argvalues` should be a tuple. This is then the intended behaviour, and therefore not an issue. - If `argnames` is a single-element array, however, it sidesteps the check at 788, `if not isinstance(argnames, (tuple, list)):`, wrongly assuming there is more than one element in `argname`, and therefore does not pack up `argvalues` into tuples. The simplest fix is to simply dedent lines 790 and 791 to check the length of argnames regardless of whether it was passed as a string or not. I'm not sure if this change is entirely safe, but it did resolve the issue in my case. _______________________________________________ pytest-commit mailing list pytest-commit@python.org https://mail.python.org/mailman/listinfo/pytest-commit