You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was writing some pytest fixtures to create containers, and I wanted to create a Network in a fixture. However, I realized that a non-context-manager interface wasn't provided for the Network class. I've already made the change here: dogukancagatay#1
Why should it be done this way?
There is a non-context-manager API for other classes, such as DockerContainer and DockerImage, and I think that Network should have one for completeness, flexibility, and ease of use in some instances.
Other references:
Include any other relevant reading material about the enhancement.
can you share your code for the fixture? normally you can yield from the fixture and then once the test suite is done, it runs the rest of your function, like __exit__ and such -- besides, why do you want to programmatically create a network that you do not also programmatically destroy?
I could have created Network with the context manager on my fixture. DockerContainer and DockerImage allows to be used outside context-manager, so why not Network have the non-context-manager way.
Activity
feat(network): Add create method to Network class (testcontainers#627)
alexanderankin commentedon Jun 30, 2024
can you share your code for the fixture? normally you can yield from the fixture and then once the test suite is done, it runs the rest of your function, like
__exit__and such -- besides, why do you want to programmatically create a network that you do not also programmatically destroy?dogukancagatay commentedon Jul 1, 2024
I could have created
Networkwith the context manager on my fixture.DockerContainerandDockerImageallows to be used outside context-manager, so why notNetworkhave the non-context-manager way.feat(network): Add create method to Network class (testcontainers#627)
alexanderankin commentedon Jul 1, 2024
does ryuk clean it up at least?
alexanderankin commentedon Jul 1, 2024
ok, ive thought about this a bit, makes sense to allow this API - I would consider it a bug also if API's were not uniform in the way you described
additionally took this opportunity to review the code and discover we are not auto-cleaning up the networks so I fixed this as well.
so i feel like it is ready to merge now once ci passes.
chore(main): release testcontainers 4.7.1 (#624)
fix(network): Now able to use Network without context, and has labels…