Code

Opened 6 years ago

Closed 5 years ago

Last modified 3 years ago

#9031 closed Uncategorized (fixed)

Small bug if typo in testcase

Reported by: guettli 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 guettli 6 years ago.

Download all attachments as: .zip

Change History (5)

Changed 6 years ago by guettli

comment:1 Changed 6 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Ready for checkin

Minor, but seems fair enough.

comment:2 Changed 5 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(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 5 years ago by russellm

(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 3 years ago by guettli

  • Cc hv@… removed
  • Easy pickings unset
  • Severity set to Normal
  • Type set to Uncategorized
  • UI/UX unset

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.