Opened 8 years ago

Closed 8 years ago

Last modified 5 years ago

#9031 closed Uncategorized (fixed)

Small bug if typo in testcase

Reported by: Thomas Güttler Owned by: nobody
Component: Testing framework Version: 1.0
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If there is a typo in a testcase, you get an exception:

user@host:~/myproj> ./manage.py test myapp.hereisatypo.testSomething
Traceback (most recent call last):
  File "./manage.py", line 11, in <module>
    execute_manager(etc.settings)
  File "/localhome/modw/django/core/management/__init__.py", line 340, in execute_manager
    utility.execute()
  File "/localhome/modw/django/core/management/__init__.py", line 295, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/localhome/modw/django/core/management/base.py", line 77, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/localhome/modw/django/core/management/base.py", line 96, in execute
    output = self.handle(*args, **options)
  File "/localhome/modw/django/core/management/commands/test.py", line 33, in handle
    failures = test_runner(test_labels, verbosity=verbosity, interactive=interactive)
  File "/localhome/modw/django/test/simple.py", line 129, in run_tests
    suite.addTest(build_test(label))
  File "/localhome/modw/django/test/simple.py", line 100, in build_test
    return TestClass(parts[2])
TypeError: 'NoneType' object is not callable

The small patch results in a better error message:

user@host:~/myproj> ./manage.py test myapp.hereisatypo.testSomething
Traceback (most recent call last):
  File "./manage.py", line 11, in <module>
    execute_manager(etc.settings)
  File "/localhome/modw/django/core/management/__init__.py", line 340, in execute_manager
    utility.execute()
  File "/localhome/modw/django/core/management/__init__.py", line 295, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/localhome/modw/django/core/management/base.py", line 77, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/localhome/modw/django/core/management/base.py", line 96, in execute
    output = self.handle(*args, **options)
  File "/localhome/modw/django/core/management/commands/test.py", line 33, in handle
    failures = test_runner(test_labels, verbosity=verbosity, interactive=interactive)
  File "/localhome/modw/django/test/simple.py", line 132, in run_tests
    suite.addTest(build_test(label))
  File "/localhome/modw/django/test/simple.py", line 102, in build_test
    parts[1], parts[0], parts[0]))
ValueError: TestCase hereisatypo not found. Searched in myapp.models and myapp.tests

Attachments (1)

9031.diff (660 bytes) - added by Thomas Güttler 8 years ago.

Download all attachments as: .zip

Change History (5)

Changed 8 years ago by Thomas Güttler

Attachment: 9031.diff added

comment:1 Changed 8 years ago by Chris Beaven

Triage Stage: UnreviewedReady for checkin

Minor, but seems fair enough.

comment:2 Changed 8 years ago by Russell Keith-Magee

Resolution: fixed
Status: newclosed

(In [9879]) Fixed #9031 -- Clarified the error message when the label used to run a specific test case method doesn't name a valid test case class. Thanks to Thomas Guettler for the suggestion and patch.

comment:3 Changed 8 years ago by Russell Keith-Magee

(In [9880]) [1.0.X] Fixed #9031 -- Clarified the error message when the label used to run a specific test case method doesn't name a valid test case class. Thanks to Thomas Guettler for the suggestion and patch.

Merge of r9879 from trunk.

comment:4 Changed 5 years ago by Thomas Güttler

Cc: hv@… removed
Easy pickings: unset
Severity: Normal
Type: Uncategorized
UI/UX: unset
Note: See TracTickets for help on using tickets.
Back to Top