Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix various issues with running test suite on "non-standard" platforms #2965

Merged
merged 4 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading