#18882 closed Bug (wontfix)

ValueError when running a test inside a thread

Reported by: ebas Owned by: nobody
Component: Testing framework Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


When running tests, unittest.installHandler is called to catch SIGINT. This is impossible when it's not on the main thread, and will throw a ValueError.

Running tests inside a thread occurs, for example, when used in conjuction with autoreload, as used in:

Using either of these will result in a ValueError.

One might argue this is an unittest bug, but i disagree. Unittest doesn't automatically install this handler, therefor its the users (django) responsibility to use it appropriately.

Branch on github:

Attachments (0)

Change History (1)

comment:1 Changed 18 months ago by lrekucki

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

Why not just run the DjangoTestSuiteRunner in a subprocess instead of a thread? That should solve this issue (and probably a bunch of others as it's far from being thread-safe).

Add Comment

Modify Ticket

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

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

Note: See TracTickets for help on using tickets.