Selaa lähdekoodia

fix: Ensure networks are actually connected to pytest container

The `network` object would never be in a list of network names (strings), and without `greedy=True` arg as the `docker-py` API docs note, the containers will not be part of the results, thus always returning an empty list which was not intended..

Now the network will properly match the current networks for pytest container, avoiding duplicate connect attempts, and the network list result will actually have containers to count when filtering by length.
polarathene 3 vuotta sitten
vanhempi
commit
04b0181980
1 muutettua tiedostoa jossa 2 lisäystä ja 2 poistoa
  1. 2 2
      test/conftest.py

+ 2 - 2
test/conftest.py

@@ -367,7 +367,7 @@ def connect_to_network(network):
             return None
 
         # make sure our container is connected to the nginx-proxy's network
-        if network not in my_networks:
+        if network.name not in my_networks:
             logging.info(f"Connecting to docker network: {network.name}")
             network.connect(my_container)
             return network
@@ -405,7 +405,7 @@ def connect_to_all_networks():
         return []
     else:
         # find the list of docker networks
-        networks = [network for network in docker_client.networks.list() if len(network.containers) > 0 and network.name != 'bridge']
+        networks = [network for network in docker_client.networks.list(greedy=True) if len(network.containers) > 0 and network.name != 'bridge']
         return [connect_to_network(network) for network in networks]