Opened 6 years ago

Closed 2 years ago

#8267 defect closed fixed (fixed)

Can not import twisted.trial.reporter without first importing unittest (or some other class)

Reported by: alex---- Owned by: Tom Most
Priority: normal Milestone:
Component: trial Keywords: tests
Cc: Jonathan Lange Branch:
Author:

Description (last modified by Thijs Triemstra)

Looks like importing reporter imports unittest, which imports _asyncrunner which import reporter which is not going to be possible while trying to import reporter.

You can work around the issue by importing unittest first (which imports _asyncrunner which imports reporter.

This was not the case in earlier versions of twisted. I am seeing it in version 16.0.0 of twisted.

>>> from twisted.trial import reporter
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/twisted/trial/reporter.py", line 29, in <module>
    from twisted.trial.unittest import makeTodo
  File "/usr/local/lib/python2.7/dist-packages/twisted/trial/unittest.py", line 16, in <module>
    from twisted.trial._asyncrunner import (
  File "/usr/local/lib/python2.7/dist-packages/twisted/trial/_asyncrunner.py", line 16, in <module>
    from twisted.trial import itrial, reporter
ImportError: cannot import name reporter
>>> from twisted.trial import unittest
>>> from twisted.trial import reporter
>>>

Change History (6)

comment:1 Changed 6 years ago by DefaultCC Plugin

Cc: Jonathan Lange added

comment:2 Changed 6 years ago by Thijs Triemstra

Description: modified (diff)

fixing markup

comment:3 Changed 5 years ago by Julian Berman

#8759 was closed as a duplicate of this ticket.

comment:4 Changed 3 years ago by Colin Watson

Keywords: review added

comment:5 Changed 2 years ago by Tom Most

Keywords: review removed
Owner: set to Tom Most

Reviewed: https://github.com/twisted/twisted/pull/1148#pullrequestreview-261527868

I will wait for a few days for further feedback on #twisted-dev in case anyone objects to merging without tests. In the meantime I'll keep this assigned to me.

comment:6 Changed 2 years ago by Tom Most

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.