diff --git a/jupyterhub/tests/conftest.py b/jupyterhub/tests/conftest.py index 9c89c0ec..d22e278a 100644 --- a/jupyterhub/tests/conftest.py +++ b/jupyterhub/tests/conftest.py @@ -77,15 +77,10 @@ def _mockservice(request, app, url=False): 'admin': True, } if url: - spec['url'] = 'http://127.0.0.1:%i' % random_port(), + spec['url'] = 'http://127.0.0.1:%i' % random_port() with mock.patch.object(jupyterhub.services.service, '_ServiceSpawner', MockServiceSpawner): - app.services = [{ - 'name': name, - 'command': mockservice_cmd, - 'url': 'http://127.0.0.1:%i' % random_port(), - 'admin': True, - }] + app.services = [spec] app.init_services() app.io_loop.add_callback(app.proxy.add_all_services, app._service_map) assert name in app._service_map diff --git a/jupyterhub/tests/mockservice.py b/jupyterhub/tests/mockservice.py index 4d377a56..d0cbf368 100644 --- a/jupyterhub/tests/mockservice.py +++ b/jupyterhub/tests/mockservice.py @@ -70,7 +70,7 @@ class OWhoAmIHandler(HubOAuthenticated, web.RequestHandler): def main(): pprint.pprint(dict(os.environ), stream=sys.stderr) - if os.environ['JUPYTERHUB_SERVICE_URL']: + if os.getenv('JUPYTERHUB_SERVICE_URL'): url = urlparse(os.environ['JUPYTERHUB_SERVICE_URL']) app = web.Application([ (r'.*/env', EnvHandler), diff --git a/jupyterhub/tests/test_api.py b/jupyterhub/tests/test_api.py index 980c4875..f1e715f0 100644 --- a/jupyterhub/tests/test_api.py +++ b/jupyterhub/tests/test_api.py @@ -723,7 +723,8 @@ def test_group_delete_users(app): @mark.services -def test_get_services(app, mockservice): +def test_get_services(app, mockservice_url): + mockservice = mockservice_url db = app.db r = api_request(app, 'services') r.raise_for_status() @@ -748,7 +749,8 @@ def test_get_services(app, mockservice): @mark.services -def test_get_service(app, mockservice): +def test_get_service(app, mockservice_url): + mockservice = mockservice_url db = app.db r = api_request(app, 'services/%s' % mockservice.name) r.raise_for_status()