소스 검색

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 년 전
부모
커밋
04b0181980
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  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]