diff --git a/batchspawner/tests/test_spawners.py b/batchspawner/tests/test_spawners.py index 79cd1e46..ee826aec 100644 --- a/batchspawner/tests/test_spawners.py +++ b/batchspawner/tests/test_spawners.py @@ -1,8 +1,11 @@ """Test BatchSpawner and subclasses""" import asyncio +import os +import pwd import re import time +from unittest import mock import pytest from jupyterhub import orm @@ -17,6 +20,15 @@ testport = 54321 +@pytest.fixture(autouse=True) +def _always_get_my_home(): + # pwd.getbwnam() is always called with the current user + # ignoring the requested name, which usually doesn't exist + getpwnam = pwd.getpwnam + with mock.patch.object(pwd, "getpwnam", lambda name: getpwnam(os.getlogin())): + yield + + class BatchDummy(BatchSpawnerRegexStates): exec_prefix = "" batch_submit_cmd = Unicode("cat > /dev/null; echo " + testjob)