mirror of
https://github.com/coddingtonbear/django-mailbox.git
synced 2026-07-09 22:38:19 +02:00
Bug fixes for Django versions 1.8 and 1.9
These are versions in which a "compatibility mode" is in place for argument handling, and things didn't work quite the way I expected
This commit is contained in:
parent
b5d5207cd8
commit
33b48b2f73
1 changed files with 9 additions and 2 deletions
|
|
@ -42,7 +42,7 @@ class CommandsTestCase(TestCase):
|
||||||
args, kwargs = handle.call_args
|
args, kwargs = handle.call_args
|
||||||
try:
|
try:
|
||||||
self.assertEqual(kwargs['mailbox_name'], mailbox_name)
|
self.assertEqual(kwargs['mailbox_name'], mailbox_name)
|
||||||
except KeyError:
|
except (AssertionError, KeyError):
|
||||||
# Handle Django 1.7
|
# Handle Django 1.7
|
||||||
# It uses optparse instead of argparse, so instead of being
|
# It uses optparse instead of argparse, so instead of being
|
||||||
# in kwargs, mailbox_name is in args
|
# in kwargs, mailbox_name is in args
|
||||||
|
|
@ -53,6 +53,13 @@ class CommandsTestCase(TestCase):
|
||||||
# Only perform this test for Django versions greater than 1.7.*. This
|
# Only perform this test for Django versions greater than 1.7.*. This
|
||||||
# is because, with optparse, too many arguments doesn't result in an
|
# is because, with optparse, too many arguments doesn't result in an
|
||||||
# error, which means this test is worthless anyway
|
# error, which means this test is worthless anyway
|
||||||
if LooseVersion(django.get_version()) >= LooseVersion('1.8'):
|
# For the "compatibility" versions, unexpected arguments aren't handled
|
||||||
|
# very well, and result in a TypeError
|
||||||
|
if (LooseVersion(django.get_version()) >= LooseVersion('1.8') and
|
||||||
|
LooseVersion(django.get_version()) < LooseVersion('1.10')):
|
||||||
|
with self.assertRaises(TypeError):
|
||||||
|
call_command('processincomingmessage', 'foo_mailbox', 'invalid_arg')
|
||||||
|
# In 1.10 and later a proper CommandError should be raised
|
||||||
|
elif LooseVersion(django.get_version()) >= LooseVersion('1.10'):
|
||||||
with self.assertRaises(CommandError):
|
with self.assertRaises(CommandError):
|
||||||
call_command('processincomingmessage', 'foo_mailbox', 'invalid_arg')
|
call_command('processincomingmessage', 'foo_mailbox', 'invalid_arg')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue