<commit_before>import os
from tornado.testing import AsyncTestCase, gen_test

from remoteappmanager.docker.async_docker_client import AsyncDockerClient
from tests.docker.config import nonlinux_config
from tests import utils


class TestAsyncDockerClient(AsyncTestCase):
    @gen_test
    def test_info(self):
        client = AsyncDockerClient()
        client.client = utils.mock_docker_client()
        response = yield client.info()
        # Test contents of response
        self.assertIsInstance(response, dict)
        self.assertIn("ID", response)

    @gen_test
    def test_real_connection(self):
        config = None
        if "DOCKER_HOST" not in os.environ:
            config = nonlinux_config()

            if not os.path.exists(config.tls_cert):
                self.skipTest("Certificates are not available. Skipping.")

        client = AsyncDockerClient(config=config)
        response = yield client.info()
        # Test contents of response
        self.assertIsInstance(response, dict)
        self.assertIn("ID", response)
<commit_msg>Silence warning for resource leak<commit_after>import os
import warnings
from tornado.testing import AsyncTestCase, gen_test

from remoteappmanager.docker.async_docker_client import AsyncDockerClient
from tests.docker.config import nonlinux_config
from tests import utils


class TestAsyncDockerClient(AsyncTestCase):
    def setUp(self):
        super().setUp()
        # Due to a python requests design choice, we receive a warning about
        # leaking connection. This is expected and pretty much out of our
        # authority but it can be annoying in tests, hence we suppress the
        # warning. See issue simphony-remote/10
        warnings.filterwarnings(action="ignore",
                                message="unclosed",
                                category=ResourceWarning)

    def tearDown(self):
        super().tearDown()
        warnings.filterwarnings(action="default",
                                message="unclosed",
                                category=ResourceWarning)

    @gen_test
    def test_info(self):
        client = AsyncDockerClient()
        client.client = utils.mock_docker_client()
        response = yield client.info()
        # Test contents of response
        self.assertIsInstance(response, dict)
        self.assertIn("ID", response)

    @gen_test
    def test_real_connection(self):
        config = None
        if "DOCKER_HOST" not in os.environ:
            config = nonlinux_config()

            if not os.path.exists(config.tls_cert):
                self.skipTest("Certificates are not available. Skipping.")

        client = AsyncDockerClient(config=config)
        response = yield client.info()
        # Test contents of response
        self.assertIsInstance(response, dict)
        self.assertIn("ID", response)

{'fraction_non_alphanumeric': 0.07576289021396002, 'fraction_numerical': 0.0007015082427218519, 'mean_word_length': 2.5384615384615383, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2259866', 'n_tokens_mistral': 742, 'n_tokens_neox': 721, 'n_words': 201}