diff --git a/Makefile b/Makefile index 1abf5e603..e122403dc 100644 --- a/Makefile +++ b/Makefile @@ -101,7 +101,7 @@ test: pythontest jstest pythontest: @echo "Running python testsuite" @echo "------------------------" - python -m tornado.testing discover -s remoteappmanager -t . -v + python -m tornado.testing discover -s remoteappmanager -t . .PHONY: jstest jstest: diff --git a/remoteappmanager/cli/tests/test_remoteappdb.py b/remoteappmanager/cli/tests/test_remoteappdb.py index 981754512..118f00802 100644 --- a/remoteappmanager/cli/tests/test_remoteappdb.py +++ b/remoteappmanager/cli/tests/test_remoteappdb.py @@ -1,5 +1,5 @@ import os -import unittest +from tornado.testing import LogTrapTestCase from unittest import mock from click.testing import CliRunner @@ -14,7 +14,7 @@ def create_docker_client(): return VirtualDockerClient.with_containers() -class TestRemoteAppDbCLI(TempMixin, unittest.TestCase): +class TestRemoteAppDbCLI(TempMixin, LogTrapTestCase): def setUp(self): super().setUp() self.db = os.path.join(self.tempdir, "test.db") diff --git a/remoteappmanager/db/tests/test_orm.py b/remoteappmanager/db/tests/test_orm.py index a4631ee64..56e60aaa7 100644 --- a/remoteappmanager/db/tests/test_orm.py +++ b/remoteappmanager/db/tests/test_orm.py @@ -1,7 +1,8 @@ import contextlib import uuid import os -import unittest + +from tornado.testing import LogTrapTestCase from remoteappmanager.db import orm from remoteappmanager.db import exceptions @@ -53,7 +54,7 @@ def fill_db(session): session.add_all(accountings) -class TestOrm(TempMixin, unittest.TestCase): +class TestOrm(TempMixin, LogTrapTestCase): def setUp(self): super().setUp() self.sqlite_file_path = os.path.join(self.tempdir, "sqlite.db") @@ -139,7 +140,7 @@ def test_apps_for_user(self): class TestOrmAppAccounting(TempMixin, ABCTestDatabaseInterface, - unittest.TestCase): + LogTrapTestCase): def setUp(self): # Setup temporary directory super().setUp() diff --git a/remoteappmanager/docker/tests/test_container_manager.py b/remoteappmanager/docker/tests/test_container_manager.py index 86700238c..e91539570 100644 --- a/remoteappmanager/docker/tests/test_container_manager.py +++ b/remoteappmanager/docker/tests/test_container_manager.py @@ -1,7 +1,7 @@ import os from unittest import mock -from tornado.testing import AsyncTestCase, gen_test +from tornado.testing import AsyncTestCase, gen_test, LogTrapTestCase from remoteappmanager.docker.container import Container from remoteappmanager.docker.docker_labels import SIMPHONY_NS_RUNINFO @@ -13,7 +13,7 @@ VirtualDockerClient) -class TestContainerManager(AsyncTestCase): +class TestContainerManager(AsyncTestCase, LogTrapTestCase): def setUp(self): super().setUp() self.manager = ContainerManager(docker_config={}, realm="myrealm") diff --git a/remoteappmanager/handlers/admin/tests/test_admin_handlers.py b/remoteappmanager/handlers/admin/tests/test_admin_handlers.py index 97d9e01b8..1db2ecd7b 100644 --- a/remoteappmanager/handlers/admin/tests/test_admin_handlers.py +++ b/remoteappmanager/handlers/admin/tests/test_admin_handlers.py @@ -1,8 +1,9 @@ +from tornado.testing import LogTrapTestCase from remoteappmanager.tests import utils from remoteappmanager.tests.mocking import dummy -class TestBaseAccess(utils.AsyncHTTPTestCase): +class TestBaseAccess(utils.AsyncHTTPTestCase, LogTrapTestCase): #: which url to poke url = "/user/johndoe" diff --git a/remoteappmanager/handlers/tests/test_base_handler.py b/remoteappmanager/handlers/tests/test_base_handler.py index 594929a4c..fcf2d02ec 100644 --- a/remoteappmanager/handlers/tests/test_base_handler.py +++ b/remoteappmanager/handlers/tests/test_base_handler.py @@ -1,3 +1,4 @@ +from tornado.testing import LogTrapTestCase from remoteappmanager.file_config import FileConfig from remoteappmanager.tests import utils @@ -5,7 +6,7 @@ from remoteappmanager.tests.temp_mixin import TempMixin -class TestBaseHandler(TempMixin, utils.AsyncHTTPTestCase): +class TestBaseHandler(TempMixin, utils.AsyncHTTPTestCase, LogTrapTestCase): def get_file_config(self): file_config = FileConfig() file_config.accounting_class = \ diff --git a/remoteappmanager/handlers/tests/test_home_handler.py b/remoteappmanager/handlers/tests/test_home_handler.py index 193bf121d..b04e97550 100644 --- a/remoteappmanager/handlers/tests/test_home_handler.py +++ b/remoteappmanager/handlers/tests/test_home_handler.py @@ -1,9 +1,11 @@ +from tornado.testing import LogTrapTestCase + from remoteappmanager.tests import utils from remoteappmanager.tests.mocking import dummy from remoteappmanager.tests.temp_mixin import TempMixin -class TestHomeHandler(TempMixin, utils.AsyncHTTPTestCase): +class TestHomeHandler(TempMixin, utils.AsyncHTTPTestCase, LogTrapTestCase): def get_app(self): app = dummy.create_application() app.hub.verify_token.return_value = { diff --git a/remoteappmanager/handlers/tests/test_register_container_handler.py b/remoteappmanager/handlers/tests/test_register_container_handler.py index cf959edfd..1eb535bda 100644 --- a/remoteappmanager/handlers/tests/test_register_container_handler.py +++ b/remoteappmanager/handlers/tests/test_register_container_handler.py @@ -1,10 +1,14 @@ +from tornado.testing import LogTrapTestCase + from remoteappmanager.tests import utils from remoteappmanager.tests.mocking import dummy from remoteappmanager.tests.temp_mixin import TempMixin from remoteappmanager.tests.utils import mock_coro_factory -class TestRegisterContainerHandler(TempMixin, utils.AsyncHTTPTestCase): +class TestRegisterContainerHandler(TempMixin, + utils.AsyncHTTPTestCase, + LogTrapTestCase): def get_app(self): app = dummy.create_application() app.hub.verify_token.return_value = { diff --git a/remoteappmanager/jupyterhub/auth/tests/test_github_whitelist_authenticator.py b/remoteappmanager/jupyterhub/auth/tests/test_github_whitelist_authenticator.py index cb1683233..9c05366ff 100644 --- a/remoteappmanager/jupyterhub/auth/tests/test_github_whitelist_authenticator.py +++ b/remoteappmanager/jupyterhub/auth/tests/test_github_whitelist_authenticator.py @@ -1,7 +1,7 @@ import os import time -from tornado.testing import AsyncTestCase, gen_test +from tornado.testing import AsyncTestCase, gen_test, LogTrapTestCase from remoteappmanager.tests.temp_mixin import TempMixin from remoteappmanager.tests.utils import mock_coro_factory @@ -11,7 +11,9 @@ from remoteappmanager.jupyterhub.auth import GitHubWhitelistAuthenticator -class TestGithubWhiteListAuthenticator(TempMixin, AsyncTestCase): +class TestGithubWhiteListAuthenticator(TempMixin, + AsyncTestCase, + LogTrapTestCase): def setUp(self): self.auth = GitHubWhitelistAuthenticator() self.auth.authenticate = mock_coro_factory(return_value="foo") diff --git a/remoteappmanager/jupyterhub/auth/tests/test_world_authenticator.py b/remoteappmanager/jupyterhub/auth/tests/test_world_authenticator.py index 5f4d04ef5..8b66e5a36 100644 --- a/remoteappmanager/jupyterhub/auth/tests/test_world_authenticator.py +++ b/remoteappmanager/jupyterhub/auth/tests/test_world_authenticator.py @@ -1,10 +1,10 @@ -from tornado.testing import AsyncTestCase, gen_test +from tornado.testing import AsyncTestCase, gen_test, LogTrapTestCase from unittest.mock import Mock from remoteappmanager.jupyterhub.auth import WorldAuthenticator -class TestWorldAuthenticator(AsyncTestCase): +class TestWorldAuthenticator(AsyncTestCase, LogTrapTestCase): @gen_test def test_basic_auth(self): auth = WorldAuthenticator() diff --git a/remoteappmanager/jupyterhub/tests/test_spawners.py b/remoteappmanager/jupyterhub/tests/test_spawners.py index ec8fa729f..2ef9eb92b 100644 --- a/remoteappmanager/jupyterhub/tests/test_spawners.py +++ b/remoteappmanager/jupyterhub/tests/test_spawners.py @@ -5,6 +5,7 @@ import sys import time from unittest import mock +from tornado.testing import LogTrapTestCase from tornado import testing from jupyterhub import orm @@ -67,7 +68,7 @@ def new_spawner(spawner_class): return spawner_class(db=db, user=user, hub=hub) -class TestSystemUserSpawner(TempMixin, testing.AsyncTestCase): +class TestSystemUserSpawner(TempMixin, testing.AsyncTestCase, LogTrapTestCase): def setUp(self): super().setUp() self.spawner = new_spawner(SystemUserSpawner) diff --git a/remoteappmanager/services/tests/test_hub.py b/remoteappmanager/services/tests/test_hub.py index 1544a1b9c..ed3649cdb 100644 --- a/remoteappmanager/services/tests/test_hub.py +++ b/remoteappmanager/services/tests/test_hub.py @@ -21,7 +21,7 @@ def get(self, url): self.flush() -class TestHub(utils.AsyncHTTPTestCase): +class TestHub(utils.AsyncHTTPTestCase, testing.LogTrapTestCase): def get_app(self): self.handler = AuthHandler handlers = [ diff --git a/remoteappmanager/services/tests/test_reverse_proxy.py b/remoteappmanager/services/tests/test_reverse_proxy.py index 238237844..47a0fab68 100644 --- a/remoteappmanager/services/tests/test_reverse_proxy.py +++ b/remoteappmanager/services/tests/test_reverse_proxy.py @@ -5,7 +5,7 @@ from tornado import gen, testing -class TestReverseProxy(testing.AsyncTestCase): +class TestReverseProxy(testing.AsyncTestCase, testing.LogTrapTestCase): @testing.gen_test def test_reverse_proxy_operations(self): coroutine_out = None diff --git a/remoteappmanager/tests/mocking/virtual/docker_client.py b/remoteappmanager/tests/mocking/virtual/docker_client.py index ea4546bd2..a4a79881d 100644 --- a/remoteappmanager/tests/mocking/virtual/docker_client.py +++ b/remoteappmanager/tests/mocking/virtual/docker_client.py @@ -1,4 +1,5 @@ import json +import logging import hashlib import uuid import requests @@ -11,6 +12,8 @@ SIMPHONY_NS_ENV, SIMPHONY_NS_RUNINFO) +log = logging.getLogger(__name__) + # internal, convenience classes. Do not export (risks name collisions with # container manager similarly named entities. @@ -245,10 +248,10 @@ def port(self, container_name_or_id, private_port): return None def start(self, *args, **kwargs): - print("VirtualDockerClient.start called with ", args, kwargs) + log.info("VirtualDockerClient.start called with ", args, kwargs) def stop(self, *args, **kwargs): - print("VirtualDockerClient.stop called with ", args, kwargs) + log.info("VirtualDockerClient.stop called with ", args, kwargs) def remove_container(self, container, *args, **kwargs): container = self._find_container(container) diff --git a/remoteappmanager/tests/test_application.py b/remoteappmanager/tests/test_application.py index 8c6b1dae1..476d71176 100644 --- a/remoteappmanager/tests/test_application.py +++ b/remoteappmanager/tests/test_application.py @@ -15,7 +15,9 @@ def __init__(self, *args, **kwargs): pass -class TestApplication(TempMixin, testing.AsyncTestCase): +class TestApplication(TempMixin, + testing.AsyncTestCase, + testing.LogTrapTestCase): def setUp(self): super().setUp() diff --git a/remoteappmanager/tests/test_netutils.py b/remoteappmanager/tests/test_netutils.py index 1f5e116d4..62d3a4606 100644 --- a/remoteappmanager/tests/test_netutils.py +++ b/remoteappmanager/tests/test_netutils.py @@ -1,6 +1,6 @@ from unittest import mock from tornado import web -from tornado.testing import AsyncHTTPTestCase, gen_test +from tornado.testing import AsyncHTTPTestCase, gen_test, LogTrapTestCase from remoteappmanager.tests.utils import mock_coro_new_callable from remoteappmanager.netutils import wait_for_http_server_2xx @@ -23,7 +23,7 @@ class LongHandler(ShortHandler): error_count = 100000 -class TestUtils(AsyncHTTPTestCase): +class TestUtils(AsyncHTTPTestCase, LogTrapTestCase): def get_app(self): app = web.Application(handlers=[('/short', ShortHandler), diff --git a/remoteappmanager/tests/test_utils.py b/remoteappmanager/tests/test_utils.py index 424df784a..9f82ec839 100644 --- a/remoteappmanager/tests/test_utils.py +++ b/remoteappmanager/tests/test_utils.py @@ -1,8 +1,8 @@ -import unittest +from tornado.testing import LogTrapTestCase from remoteappmanager import utils -class TestUtils(unittest.TestCase): +class TestUtils(LogTrapTestCase): def test_parse_volume_string(self): self.assertEqual(utils.parse_volume_string("/foo:/bar:ro"), ("/foo", "/bar", "ro"))