Fix `mock.patch.dict` to be stopped with `mock.patch.stopall` (#17606)

As the function was not registering in the active patches, the mocks
started by `mock.patch.dict` were not being stopped when
`mock.patch.stopall` was being called.
3 files changed