Skip to content

Commit

Permalink
Merge pull request #2965 from Uninett/test/fix-macos-test-issues
Browse files Browse the repository at this point in the history
Fix various issues with running test suite on "non-standard" platforms
  • Loading branch information
lunkwill42 authored Sep 16, 2024
2 parents 5c1b734 + 796a6a1 commit b7325f7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.d/+macos-testsuite-fixes.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make the test suite easier to run under MacOS
8 changes: 8 additions & 0 deletions python/nav/Snmp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"""
from __future__ import absolute_import
import os
import sys

BACKEND = None

Expand All @@ -35,6 +37,12 @@
# These wildcard imports are informed, not just accidents.
# pylint: disable=W0401
if BACKEND == 'pynetsnmp':
if sys.platform == "darwin" and not os.getenv("DYLD_LIBRARY_PATH"):
# horrible workaround for MacOS problems, described at length at
# https://hynek.me/articles/macos-dyld-env/
os.environ["DYLD_LIBRARY_PATH"] = os.getenv(
"LD_LIBRARY_PATH", "/usr/local/opt/openssl/lib"
)
from .pynetsnmp import *
else:
raise ImportError("No supported SNMP backend was found")
Expand Down
8 changes: 5 additions & 3 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import importlib.util
import io
import platform
import re
import shlex
from itertools import cycle
Expand Down Expand Up @@ -41,10 +42,11 @@ def pytest_configure(config):

bootstrap_django('pytest')

# Install custom reactor for Twisted tests
from nav.ipdevpoll.epollreactor2 import install
if platform.system() == 'Linux':
# Install custom reactor for Twisted tests
from nav.ipdevpoll.epollreactor2 import install

install()
install()

# Setup test environment for Django
from django.test.utils import setup_test_environment
Expand Down
3 changes: 3 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ setenv =
django32: DJANGO_VER=32
django40: DJANGO_VER=40
passenv =
C_INCLUDE_PATH
GITHUB_ACTIONS
GITHUB_RUN_ID
USER
Expand All @@ -56,6 +57,8 @@ passenv =
PGPASSWORD
WORKSPACE
DISPLAY
DYLD_LIBRARY_PATH
LD_LIBRARY_PATH
allowlist_externals =
sh
sed
Expand Down

0 comments on commit b7325f7

Please sign in to comment.