Skip to content

Commit

Permalink
Merge pull request #531 from minrk/bump-dev
Browse files Browse the repository at this point in the history
update some test dependencies
  • Loading branch information
minrk authored Feb 12, 2025
2 parents ad0f724 + 4f75acc commit 6b3076e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
3 changes: 1 addition & 2 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
netifaces
notebook<7
psutil
pytest>=3.6
pytest-asyncio>=0.25
pytest-cov
25 changes: 15 additions & 10 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
import inspect
import json
import os
from socket import AddressFamily
from textwrap import indent
from unittest import mock

import jupyterhub
import netifaces
import psutil
import pytest
import pytest_asyncio
from docker import from_env as docker_from_env
Expand Down Expand Up @@ -38,15 +39,19 @@
# on GHA, the ip for hostname resolves to a 10.x
# address that is not connectable from within containers
# but the docker0 address is connectable
docker_interfaces = sorted(
iface for iface in netifaces.interfaces() if 'docker' in iface
)
if docker_interfaces:
iface = docker_interfaces[0]
print(f"Found docker interfaces: {docker_interfaces}, using {iface}")
MockHub.hub_connect_ip = netifaces.ifaddresses(docker_interfaces[0])[
netifaces.AF_INET
][0]['addr']
for iface, addrs in psutil.net_if_addrs().items():
if 'docker' not in iface:
continue
ipv4_addrs = [addr for addr in addrs if addr.family == AddressFamily.AF_INET]
if not ipv4_addrs:
print(f"No ipv4 addr for {iface}: {addrs}")
continue
ipv4 = ipv4_addrs[0]
print(f"Found docker interfaces, using {iface}: {ipv4}")
MockHub.hub_connect_ip = ipv4.address
break
else:
print(f"Did not find docker interface in: {', '.join(psutil.net_if_addrs())}")


def pytest_collection_modifyitems(items):
Expand Down

0 comments on commit 6b3076e

Please sign in to comment.