Exemple #1
0
 def test_invalid_formdata_content_transfer_encoding(self):
     form = helpers.FormData()
     invalid_vals = [0, 0.1, {}, [], b'foo']
     for invalid_val in invalid_vals:
         with self.assertRaises(TypeError):
             form.add_field('foo',
                            'bar',
                            content_transfer_encoding=invalid_val)
Exemple #2
0
 def test_invalid_formdata_params2(self):
     with self.assertRaises(TypeError):
         helpers.FormData('as')  # 2-char str is not allowed
Exemple #3
0
 def test_invalid_formdata_params(self):
     with self.assertRaises(TypeError):
         helpers.FormData('asdasf')
Exemple #4
0
def test_invalid_formdata_filename():
    form = helpers.FormData()
    invalid_vals = [0, 0.1, {}, [], b'foo']
    for invalid_val in invalid_vals:
        with pytest.raises(TypeError):
            form.add_field('foo', 'bar', filename=invalid_val)
Exemple #5
0
def test_invalid_formdata_params2():
    with pytest.raises(TypeError):
        helpers.FormData('as')  # 2-char str is not allowed
Exemple #6
0
def test_invalid_formdata_params():
    with pytest.raises(TypeError):
        helpers.FormData('asdasf')
Exemple #7
0
def test_formdata_field_name_is_not_quoted():
    form = helpers.FormData(quote_fields=False)
    form.add_field("emails[]", "*****@*****.**", content_type="multipart/form-data")
    res = b"".join(form("ascii"))
    assert b'name="emails[]"' in res