gh-109218: Refactor tests for the complex() constructor by serhiy-storchaka · Pull Request #119635 · python/cpython (original) (raw)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I once added common FakePath class which implements the __path__ method, and it is now used in many tests for the path protocol. I proposed to add similar FakeIndex, FakeFloat, etc, but Raymond rejected this idea. Here I use the Mock prefix which looks more neutral and test specific than Fake. Different tests currently use similar classes with different names. The most common prefix is perhaps My. Prefix Supports cannot be used because it can conflict with typing.SupportIndex, etc. Suffix Like can conflict with os.PathLike.

I see that several tests use the With prefix: WithStr, WithRepr, WithIterAnext, etc. What do you think about WithIndex?