Merge pull request #21410 from edx/py3-fix-too-few-arguments-bug
BOM-400, BOM-395, BOM-394, BOM-390, BOM-381, BOM-369, BOM-306, BOM-303
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")
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import six
|
||||
|
||||
from django.core.management import call_command
|
||||
from django.core.management.base import CommandError
|
||||
from django.test import TestCase
|
||||
@@ -46,7 +48,11 @@ class CreateFakeCertTest(TestCase):
|
||||
self.assertEqual(cert.mode, 'honor')
|
||||
|
||||
def test_too_few_args(self):
|
||||
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_KEY'
|
||||
with self.assertRaisesRegexp(CommandError, errstring):
|
||||
self._run_command(self.USERNAME)
|
||||
|
||||
def _run_command(self, *args, **kwargs):
|
||||
|
||||
@@ -6,6 +6,7 @@ from __future__ import absolute_import
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
import six
|
||||
from six import StringIO
|
||||
import subprocess
|
||||
import unittest
|
||||
@@ -73,7 +74,10 @@ class TestGitAddCourse(SharedModuleStoreTestCase):
|
||||
Validate argument checking
|
||||
"""
|
||||
# No argument given.
|
||||
self.assertCommandFailureRegexp('Error: too few arguments')
|
||||
if six.PY2:
|
||||
self.assertCommandFailureRegexp('Error: too few arguments')
|
||||
else:
|
||||
self.assertCommandFailureRegexp('Error: the following arguments are required: repository_url')
|
||||
# Extra/Un-named arguments given.
|
||||
self.assertCommandFailureRegexp(
|
||||
'Error: unrecognized arguments: blah blah blah',
|
||||
|
||||
Reference in New Issue
Block a user