Opened 2 years ago

Closed 2 years ago

#5873 enhancement closed fixed (fixed)

switch all synchronous trial unit tests to using SynchronousTestCase

Reported by: exarkun Owned by: exarkun
Priority: normal Milestone: Python 3.3 Minimal
Component: trial Keywords:
Cc: Branch: branches/sync-trial-tests-5873
(diff, github, buildbot, log)
Author: exarkun Launchpad Bug:

Description

Many trial unit tests don't require the reactor spinning features of twisted.trial.unittest.TestCase. To aid in porting trial to Python 3, make them use SynchronousTestCase instead, which will be ported before TestCase (thus allowing for easier test bootstrapping).

Change History (6)

comment:1 Changed 2 years ago by exarkun

  • Component changed from core to trial

comment:2 Changed 2 years ago by exarkun

  • Author set to exarkun
  • Branch set to branches/sync-trial-tests-5873

(In [35255]) Branching to 'sync-trial-tests-5873'

comment:3 Changed 2 years ago by exarkun

  • Keywords review added
  • Owner changed from exarkun to itamar

Okay. I certainly switched a lot of them. Hopefully I didn't miss any.

comment:4 Changed 2 years ago by itamar

  • Keywords review removed
  • Owner changed from itamar to exarkun

Hooray for less reactor dependencies. There a few cases you may have missed that are left:

  1. Any reason you didn't do weird.TestBleeding? Note it doesn't return a Deferred.
  2. test_test_visitor.py looks like it could be switched too.
  3. The various InterruptedTest instances in test_keyboard.py.
  4. test_doctest could be switched.
  5. MockTest in test_shouldStop in test_runner.

Once you change those, please merge. Thanks!

comment:5 Changed 2 years ago by exarkun

Any reason you didn't do weird.TestBleeding? Note it doesn't return a Deferred.

I didn't want to think about it hard enough. You're right, it can be switched. Done in r35350.

test_test_visitor.py looks like it could be switched too.

Visiting is abstractly synchronous, but I didn't port the visitor API to SynchronousTestCase. It's deprecated so not worth it.

The various InterruptedTest instances in test_keyboard.py.

Yes, but SynchronousTestCase does not handle C-c the same way as TestCase yet :/ I'm filing another ticket for that, but I'm not sure it is terribly high priority.

test_doctest could be switched.

Argh, but doctests... :( Okay, I guess so. Done in r35351.

MockTest in test_shouldStop in test_runner.

There's three versions of this test, DryRunTest, PyunitDryRunTest, and SynchronousDryRunTest, each testing a different TestCase implementation. So I think the one subclassing twisted.trial.unittest.TestCase should stay.

comment:6 Changed 2 years ago by exarkun

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

(In [35352]) Merge sync-trial-tests-5873

Author: exarkun
Reviewer: itamar
Fixes: #5873

Switch many of trial's own unit tests from twisted.trial.unittest.TestCase
to twisted.trial.unittest.SynchronousTestCase. This removes reactor-related
code from the tests of any functionality that does not depend on the reactor.

Note: See TracTickets for help on using tickets.