Fixed all py3 tests with AssertionError: "Error: too few arguments"
This commit is contained in:
@@ -23,7 +23,10 @@ class TestArgParsing(TestCase):
|
||||
super(TestArgParsing, self).setUp()
|
||||
|
||||
def test_no_args(self):
|
||||
errstring = "Error: too few arguments"
|
||||
if six.PY2:
|
||||
errstring = "Error: too few arguments"
|
||||
else:
|
||||
errstring = "Error: the following arguments are required: modulestore, user, org, number, run"
|
||||
with self.assertRaisesRegexp(CommandError, errstring):
|
||||
call_command('create_course')
|
||||
|
||||
|
||||
@@ -21,7 +21,11 @@ class TestDeleteOrphan(TestOrphanBase):
|
||||
"""
|
||||
Test delete_orphans command with no arguments
|
||||
"""
|
||||
with self.assertRaisesRegexp(CommandError, 'Error: too few arguments'):
|
||||
if six.PY2:
|
||||
errstring = 'Error: too few arguments'
|
||||
else:
|
||||
errstring = 'Error: the following arguments are required: course_id'
|
||||
with self.assertRaisesRegexp(CommandError, errstring):
|
||||
call_command('delete_orphans')
|
||||
|
||||
@ddt.data(ModuleStoreEnum.Type.split, ModuleStoreEnum.Type.mongo)
|
||||
|
||||
@@ -25,7 +25,10 @@ class TestArgParsingCourseExport(unittest.TestCase):
|
||||
"""
|
||||
Test export command with no arguments
|
||||
"""
|
||||
errstring = "Error: too few arguments"
|
||||
if six.PY2:
|
||||
errstring = "Error: too few arguments"
|
||||
else:
|
||||
errstring = "Error: the following arguments are required: course_id, output_path"
|
||||
with self.assertRaisesRegexp(CommandError, errstring):
|
||||
call_command('export')
|
||||
|
||||
|
||||
@@ -29,7 +29,11 @@ class TestForcePublish(SharedModuleStoreTestCase):
|
||||
"""
|
||||
Test 'force_publish' command with no arguments
|
||||
"""
|
||||
errstring = "Error: too few arguments"
|
||||
if six.PY2:
|
||||
errstring = "Error: too few arguments"
|
||||
else:
|
||||
errstring = "Error: the following arguments are required: course_key"
|
||||
|
||||
with self.assertRaisesRegexp(CommandError, errstring):
|
||||
call_command('force_publish')
|
||||
|
||||
|
||||
@@ -62,8 +62,15 @@ class TestGitExport(CourseTestCase):
|
||||
with self.assertRaisesRegexp(CommandError, 'Error: unrecognized arguments:*'):
|
||||
call_command('git_export', 'blah', 'blah', 'blah', stderr=StringIO())
|
||||
|
||||
with self.assertRaisesMessage(CommandError, 'Error: too few arguments'):
|
||||
call_command('git_export', stderr=StringIO())
|
||||
if six.PY2:
|
||||
with self.assertRaisesMessage(CommandError, 'Error: too few arguments'):
|
||||
call_command('git_export', stderr=StringIO())
|
||||
else:
|
||||
with self.assertRaisesMessage(
|
||||
CommandError,
|
||||
'Error: the following arguments are required: course_loc, git_url'
|
||||
):
|
||||
call_command('git_export', stderr=StringIO())
|
||||
|
||||
# Send bad url to get course not exported
|
||||
with self.assertRaisesRegexp(CommandError, six.text_type(GitExportError.URL_BAD)):
|
||||
|
||||
@@ -3,6 +3,8 @@ Unittests for migrating a course to split mongo
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import six
|
||||
|
||||
from django.core.management import CommandError, call_command
|
||||
from django.test import TestCase
|
||||
|
||||
@@ -24,7 +26,10 @@ class TestArgParsing(TestCase):
|
||||
"""
|
||||
Test the arg length error
|
||||
"""
|
||||
errstring = "Error: too few arguments"
|
||||
if six.PY2:
|
||||
errstring = "Error: too few arguments"
|
||||
else:
|
||||
errstring = "Error: the following arguments are required: course_key, email"
|
||||
with self.assertRaisesRegexp(CommandError, errstring):
|
||||
call_command("migrate_to_split")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user