/usr/lib/python3/dist-packages/panoramisk/testing.py is in python3-panoramisk 1.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from . import manager
from . import utils
try:
from unittest import mock
except ImportError: # pragma: no cover
import mock # NOQA
MagicMock = mock.MagicMock
patch = mock.patch
call = mock.call
class Connection(manager.Connection):
debug_count = [0]
def connection_made(self, transport):
super(Connection, self).connection_made(transport)
self.transport = MagicMock()
def send(self, data, as_list=False):
utils.IdGenerator.reset(uid='transaction_uid')
future = super(Connection, self).send(data, as_list=as_list)
if self.factory.stream is not None:
with open(self.factory.stream, 'rb') as fd:
for resp in fd.read().split(b'\n\n'):
self.data_received(resp + b'\n\n')
if future.done():
break
if not future.done(): # pragma: no cover
print(self.responses)
raise AssertionError("Future's result was never set")
return future
class Manager(manager.Manager):
fixtures_dir = None
def __init__(self, **config):
self.defaults.update(
connection_class=Connection,
stream=None)
super(Manager, self).__init__(**config)
self.stream = self.config.get('stream')
self.loop = utils.asyncio.get_event_loop()
protocol = Connection()
protocol.factory = manager
protocol.connection_made(mock.MagicMock())
future = utils.asyncio.Future()
future.set_result((mock.MagicMock(), protocol))
self.protocol = protocol
self.connection_made(future)
utils.IdGenerator.reset(uid='transaction_uid')
utils.EOL = '\n'
|