twisted / twisted/twisted

twisted.test.test_task._FakeReactor is an unverified fake with bugs

Open
#11,673 0 comments 0 reactions 1 assignee View on GitHub

@exarkun is already working on this.

Since Sep 16, 2022.

bug
Dominant language
Python
Stars
6k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
10

Description

Describe the incorrect behavior you saw

_FakeReactor is a helper used to test twisted.internet.task.react. It purports to implement IReactorTime and IReactorCore. However, it doesn't.

It uses twisted.internet.task.Clock for its IReactorTime implementation and this is more or less okay, so far as it goes. It brings its own novel implementation of IReactorCore and this is missing pieces and has errors in the pieces it does have:

  • running is not given the correct value at the correct times. It becomes True as soon as run is called but in a real reactor it does not change this way until the during startup phase.
  • Similarly, it becomes False as soon as stop is called. A real reactor does not change this way until the during shutdown phase.
  • It does not implement any after phases.

These are the errors and omissions that are either readily apparent by reading the implementation or which came up while working on #11650.

Most of the functionality here does not actually involve I/O (and at worst we have Clock for the pieces might). Instead of having an unverified fake of some pure functions, let's just share the pure functions between implementation and tests.

I suggest factoring these pieces out of ReactorBase so they can be shared and then using them to replace _FakeReactor.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.