import os
import pytest
import logging
import functools

import devns


@pytest.fixture
def config():
    return devns.Config()


@pytest.fixture
def logger(request):
    return logging.getLogger(request.node.nodeid)


@pytest.fixture
def parse_args(config):
    return functools.partial(devns.cli.parse_args, config=config)


@pytest.fixture
def server(config):
    return devns.server.DevNS(config)


@pytest.fixture
def resolver(config, server):
    resolver = os.path.abspath("./resolver")
    if not os.path.isdir(resolver):
        os.mkdir(resolver)
    config.resolver_dir = resolver
    yield resolver
    for item in os.listdir(resolver):
        os.unlink(os.path.join(resolver, item))
    os.rmdir(resolver)

@@ -64,16 +64,44 @@
  devns%0A%0A
+from mock import MagicMock%0A%0A
 %0A@pytest
@@ -729,20 +729,465 @@
  os.rmdir(resolver)%0A
+%0A%0Aclass Connection(object):%0A    def __init__(self, responses, expected):%0A        self.responses = responses%0A        self.expected = expected%0A%0A    settimeout = MagicMock()%0A    bind = MagicMock()%0A    sendto = MagicMock()%0A%0A    def getsockname(self):%0A        return %220.0.0.0%22, 53535%0A%0A    def recvfrom(self, length):%0A        response = self.responses.pop()%0A        if isinstance(response, tuple):%0A            return response%0A        raise response()%0A

Add a socket mock