wolever / parameterized

Parameterized testing with any Python test framework
Other
833 stars 105 forks source link

bytes as parameter crashes the expansion #134

Closed JaimeRoelandts closed 1 year ago

JaimeRoelandts commented 2 years ago

Using bytes as input parameter of a unittest will crash due to expansion issues.

e.g.

@parameterized.expand([                                                                                                                                                                                                                                                        
        ("a"*16),                                 #is fine                                                                                                                                                                                                                                 
        ("a" * 8 + "b" * 8),                   #is fine                                                                                                                                                                                                                                   
        (b"abcd" * 4)                          #will crash                                                                                                                                                                                                                                    
        ])                                                                                                                                                                                                                                                                         
    def test_value(self, case): 
        self.assertTrue(True)

Error message:

ERROR: test_value_2 (__main__.TestVal)                                                                                                                                                                                                                                       
----------------------------------------------------------------------                                                                                                                                                                                                             
Traceback (most recent call last):                                                                                                                                                                                                                                                 
  File "~/.local/lib/python3.9/site-packages/parameterized/parameterized.py", line 392, in standalone_func                                                                                                                                                            
    return func(*(a + p.args), **p.kwargs)                                                                                                                                                                                                                                         
TypeError: test_value() takes 2 positional arguments but 17 were given     
KurumiSerori commented 2 years ago

+1 however this can be avoided by an encoding/decoding (e.g., Base64)

wolever commented 1 year ago

Fixed https://github.com/wolever/parameterized/pull/157