예제 #1
0
 def assert_basename(self, test_case, response, value):
     """Implies ``attachement is True``."""
     ascii_name = encode_basename_ascii(value)
     utf8_name = encode_basename_utf8(value)
     check_utf8 = False
     check_ascii = False
     if ascii_name == utf8_name:  # Only ASCII characters.
         check_ascii = True
         if "filename*=" in response['Content-Disposition']:
             check_utf8 = True
     else:
         check_utf8 = True
         if "filename=" in response['Content-Disposition']:
             check_ascii = True
     if check_ascii:
         test_case.assertIn('filename={name}'.format(name=ascii_name),
                            response['Content-Disposition'])
     if check_utf8:
         test_case.assertIn(
             "filename*=UTF-8''{name}".format(name=utf8_name),
             response['Content-Disposition'])
예제 #2
0
 def assert_basename(self, test_case, response, value):
     """Implies ``attachement is True``."""
     ascii_name = encode_basename_ascii(value)
     utf8_name = encode_basename_utf8(value)
     check_utf8 = False
     check_ascii = False
     if ascii_name == utf8_name:  # Only ASCII characters.
         check_ascii = True
         if "filename*=" in response['Content-Disposition']:
             check_utf8 = True
     else:
         check_utf8 = True
         if "filename=" in response['Content-Disposition']:
             check_ascii = True
     if check_ascii:
         test_case.assertIn('filename="{name}"'.format(
             name=ascii_name),
             response['Content-Disposition'])
     if check_utf8:
         test_case.assertIn(
             "filename*=UTF-8''{name}".format(name=utf8_name),
             response['Content-Disposition'])
예제 #3
0
 def assert_basename(self, test_case, response, value):
     """Implies ``attachement is True``."""
     ascii_name = encode_basename_ascii(value)
     utf8_name = encode_basename_utf8(value)
     check_utf8 = False
     check_ascii = False
     if ascii_name == utf8_name:  # Only ASCII characters.
         check_ascii = True
         if "filename*=" in response["Content-Disposition"]:
             check_utf8 = True
     else:
         check_utf8 = True
         if "filename=" in response["Content-Disposition"]:
             check_ascii = True
     if check_ascii:
         test_case.assertIn(
             f'filename="{ascii_name}"', response["Content-Disposition"],
         )
     if check_utf8:
         test_case.assertIn(
             f"filename*=UTF-8''{utf8_name}", response["Content-Disposition"],
         )