Avoid changing the type of socket.socket to function.#50
Conversation
|
Hi @matthewwardrop ! This is an interesting change - how would this impact the docker package's subclassing? Would this allow the package to instantiate Can you cadd a test to ensure that this new change to return a class remains tested in the future? |
|
Hi @miketheman! Thanks for your review. Currently, With this implementation, things behave like so: which has the desired behaviour. The only way a subclass could be instantiated is if they override the I'll add a test that checks that the type of |
095e234 to
c831c14
Compare
|
Code Climate has analyzed commit c831c14 and detected 0 issues on this pull request. View more on Code Climate. |
|
Thanks @matthewwardrop ! I'll include this in the next release - probably sometime later this month. |
|
Thanks @miketheman ! |
Thanks for providing this really useful extension to
pytest.Recently, using
pytest-socketinterfered with thedockerpackage, which started subclassingsocket.socket; and obviously failed since this package changes it to be a function rather than a class.In this patch, I've replaced the socket guard with a class deriving from
socket.socket, but overriding the__new__method such that any attempt to instantiate it results in the same error as before.