Opened 5 years ago

Closed 5 years ago

#5873 enhancement closed fixed (fixed)

switch all synchronous trial unit tests to using SynchronousTestCase

Reported by: Jean-Paul Calderone Owned by: Jean-Paul Calderone
Priority: normal Milestone: Python 3.3 Minimal
Component: trial Keywords:
Cc: Branch: branches/sync-trial-tests-5873
branch-diff, diff-cov, branch-cov, buildbot
Author: exarkun

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 5 years ago by Jean-Paul Calderone

Component: coretrial

comment:2 Changed 5 years ago by Jean-Paul Calderone

Author: exarkun
Branch: branches/sync-trial-tests-5873

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

comment:3 Changed 5 years ago by Jean-Paul Calderone

Keywords: review added
Owner: changed from Jean-Paul Calderone to Itamar Turner-Trauring

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

comment:4 Changed 5 years ago by Itamar Turner-Trauring

Keywords: review removed
Owner: changed from Itamar Turner-Trauring to Jean-Paul Calderone

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 5 years ago by Jean-Paul Calderone

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 5 years ago by Jean-Paul Calderone

Resolution: fixed
Status: newclosed

(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.