import os
import sys

# Force this to happen before loading django
try:
    os.environ["DJANGO_SETTINGS_MODULE"] = "testtinymce.settings"
    test_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    sys.path.insert(0, test_dir)
except ImportError:
    pass
else:
    import django
    from django.conf import settings
    from django.test.utils import get_runner


def runtests():
    django.setup()
    TestRunner = get_runner(settings)
    test_runner = TestRunner(verbosity=1, interactive=True)
    failures = test_runner.run_tests(["tinymce"])
    sys.exit(bool(failures))


if __name__ == "__main__":
    runtests()

import argparse
import os
import sys

# Force this to happen before loading django
try:
    os.environ["DJANGO_SETTINGS_MODULE"] = "testtinymce.settings"
    test_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    sys.path.insert(0, test_dir)
except ImportError:
    pass
else:
    import django
    from django.conf import settings
    from django.test.utils import get_runner


def runtests(verbosity=1, failfast=False):
    django.setup()
    TestRunner = get_runner(settings)
    test_runner = TestRunner(interactive=True, verbosity=verbosity, failfast=failfast)
    failures = test_runner.run_tests(["tinymce"])
    sys.exit(bool(failures))


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Run the django-tinymce test suite.")
    parser.add_argument(
        "-v",
        "--verbosity",
        default=1,
        type=int,
        choices=[0, 1, 2, 3],
        help="Verbosity level; 0=minimal output, 1=normal output, 2=all output",
    )
    parser.add_argument(
        "--failfast",
        action="store_true",
        help="Stop running the test suite after first failed test.",
    )
    options = parser.parse_args()
    runtests(verbosity=options.verbosity, failfast=options.failfast)

Add ability to run tests with verbosity and failfast options
Add ability to run tests with verbosity and failfast options

+ import argparse
  import os
  import sys
  
  # Force this to happen before loading django
  try:
      os.environ["DJANGO_SETTINGS_MODULE"] = "testtinymce.settings"
      test_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
      sys.path.insert(0, test_dir)
  except ImportError:
      pass
  else:
      import django
      from django.conf import settings
      from django.test.utils import get_runner
  
  
- def runtests():
+ def runtests(verbosity=1, failfast=False):
      django.setup()
      TestRunner = get_runner(settings)
-     test_runner = TestRunner(verbosity=1, interactive=True)
+     test_runner = TestRunner(interactive=True, verbosity=verbosity, failfast=failfast)
      failures = test_runner.run_tests(["tinymce"])
      sys.exit(bool(failures))
  
  
  if __name__ == "__main__":
-     runtests()
+     parser = argparse.ArgumentParser(description="Run the django-tinymce test suite.")
+     parser.add_argument(
+         "-v",
+         "--verbosity",
+         default=1,
+         type=int,
+         choices=[0, 1, 2, 3],
+         help="Verbosity level; 0=minimal output, 1=normal output, 2=all output",
+     )
+     parser.add_argument(
+         "--failfast",
+         action="store_true",
+         help="Stop running the test suite after first failed test.",
+     )
+     options = parser.parse_args()
+     runtests(verbosity=options.verbosity, failfast=options.failfast)
  
Add ability to run tests with verbosity and failfast options
## Code Before:
import os
import sys

# Force this to happen before loading django
try:
    os.environ["DJANGO_SETTINGS_MODULE"] = "testtinymce.settings"
    test_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    sys.path.insert(0, test_dir)
except ImportError:
    pass
else:
    import django
    from django.conf import settings
    from django.test.utils import get_runner


def runtests():
    django.setup()
    TestRunner = get_runner(settings)
    test_runner = TestRunner(verbosity=1, interactive=True)
    failures = test_runner.run_tests(["tinymce"])
    sys.exit(bool(failures))


if __name__ == "__main__":
    runtests()

## Instruction:
Add ability to run tests with verbosity and failfast options
## Code After:
import argparse
import os
import sys

# Force this to happen before loading django
try:
    os.environ["DJANGO_SETTINGS_MODULE"] = "testtinymce.settings"
    test_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    sys.path.insert(0, test_dir)
except ImportError:
    pass
else:
    import django
    from django.conf import settings
    from django.test.utils import get_runner


def runtests(verbosity=1, failfast=False):
    django.setup()
    TestRunner = get_runner(settings)
    test_runner = TestRunner(interactive=True, verbosity=verbosity, failfast=failfast)
    failures = test_runner.run_tests(["tinymce"])
    sys.exit(bool(failures))


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Run the django-tinymce test suite.")
    parser.add_argument(
        "-v",
        "--verbosity",
        default=1,
        type=int,
        choices=[0, 1, 2, 3],
        help="Verbosity level; 0=minimal output, 1=normal output, 2=all output",
    )
    parser.add_argument(
        "--failfast",
        action="store_true",
        help="Stop running the test suite after first failed test.",
    )
    options = parser.parse_args()
    runtests(verbosity=options.verbosity, failfast=options.failfast)
