diff --git a/src/postorius/tests/mailman_api_tests/test_address_activation.py b/src/postorius/tests/mailman_api_tests/test_address_activation.py
index 8bd277a..3ea3316 100644
--- a/src/postorius/tests/mailman_api_tests/test_address_activation.py
+++ b/src/postorius/tests/mailman_api_tests/test_address_activation.py
@@ -126,7 +126,8 @@
@override_settings(
EMAIL_BACKEND='django.core.mail.backends.locmem.EmailBackend',
- EMAIL_CONFIRMATION_FROM='mailman@mostdesirable.org')
+ EMAIL_CONFIRMATION_FROM='mailman@mostdesirable.org',
+ ALLOWED_HOSTS=['another-virtualhost'])
def test_confirmation_link(self):
# The profile obj can send out a confirmation email.
# Simulate a VirtualHost with a different name
diff --git a/src/postorius/tests/mailman_api_tests/test_list_bans.py b/src/postorius/tests/mailman_api_tests/test_list_bans.py
index a071b7a..7e315e4 100644
--- a/src/postorius/tests/mailman_api_tests/test_list_bans.py
+++ b/src/postorius/tests/mailman_api_tests/test_list_bans.py
@@ -19,6 +19,9 @@
from __future__ import absolute_import, print_function, unicode_literals
+import django
+
+from distutils.version import StrictVersion
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
@@ -58,9 +61,16 @@
response = self.client.get(self.url)
self.assertEqual(response.status_code, 200)
self.assertTrue('addban_form' in response.context)
- self.assertContains(
- response, '')
+ if StrictVersion(django.get_version()) < StrictVersion('1.10'):
+ # Django < 1.10 XXX: remove when support for 1.9 is dropped
+ self.assertContains(
+ response, '')
+ else:
+ # Django 1.10
+ self.assertContains(
+ response, '')
self.assertContains(
response, '')
diff --git a/src/postorius/views/user.py b/src/postorius/views/user.py
index 77d35dc..28c71d5 100644
--- a/src/postorius/views/user.py
+++ b/src/postorius/views/user.py
@@ -102,7 +102,8 @@
for form, address in zip(formset.forms, mm_user.addresses):
preferences = address.preferences
for key in form.fields.keys():
- if form.cleaned_data[key] is not None:
+ if (key in form.cleaned_data and
+ form.cleaned_data[key] is not None):
# None: nothing set yet. Remember to remove this
# test when Mailman accepts None as a
# "reset to default" value.