# Path: src/foolscap/util.py
# class AsyncAND(defer.Deferred):
#     def __init__(self, deferredList):
#     def _cbDeferred(self, result, succeeded):
# def get_local_ip_for(target='A.ROOT-SERVERS.NET'):
# def format_time(when, mode):
# def move_into_place(source, dest):
# def isSubstring(small, big):
# def allocate_tcp_port():
# def _make_socket():
# def ensure_tuple_str(input_tuple):
# def ensure_dict_binary(d):
# def ensure_dict_str(d):
# def ensure_dict_str_keys(d):
# FORMAT_TIME_MODES = ["short-local", "long-local", "utc", "epoch"]


import gc
import re
import sys
    from twisted.python import log
from twisted.python import log
from twisted.trial import unittest
from twisted.internet.main import CONNECTION_LOST, CONNECTION_DONE
from twisted.python.failure import Failure
from twisted.application import service
from foolscap.tokens import Violation
from foolscap.eventual import flushEventualQueue
from foolscap.test.common import HelperTarget, TargetMixin, ShouldFailMixin
from foolscap.test.common import RIMyTarget, Target, TargetWithoutInterfaces, \
     BrokenTarget, MakeTubsMixin
from foolscap.api import RemoteException, DeadReferenceError
from foolscap.call import CopiedFailure
from foolscap.logging import log as flog
from ..util import long_type
        self.assertTrue(f.check(Violation))
        self.assertTrue(re.search(r'RIMyTarget\(.*\) does not offer bogus',
                                  str(f)))
        self.assertFalse(f.check(RemoteException))

    def _examine_remote_violation(self, r, should_be_remote):
        f = r[0]
        if should_be_remote:
            self.assertTrue(f.check(RemoteException))
            self.assertFalse(f.check(Violation))
            f2 = f.value.failure
        else:
            self.assertFalse(f.check(RemoteException))
            self.assertTrue(f.check(Violation))
            f2 = f
        self.assertTrue(isinstance(f2, CopiedFailure))
        self.assertTrue(f2.check(Violation))
        self.failUnlessSubstring("STRING token rejected by IntegerConstraint",
                                 f2.value)
        self.failUnlessSubstring("<RootUnslicer>.<methodcall", f2.value)
        self.failUnlessSubstring(" methodname=add", f2.value)
        self.failUnlessSubstring("<arguments arg[b]>", f2.value)
        self.assertFalse(f2.check(RemoteException))

    def _examine_remote_attribute_error(self, r, should_be_remote):
        f = r[0]
        if should_be_remote:
            self.assertTrue(f.check(RemoteException))
            self.assertFalse(f.check(AttributeError))
            f2 = f.value.failure

# Path: src/foolscap/util.py
# class AsyncAND(defer.Deferred):
#     def __init__(self, deferredList):
#     def _cbDeferred(self, result, succeeded):
# def get_local_ip_for(target='A.ROOT-SERVERS.NET'):
# def format_time(when, mode):
# def move_into_place(source, dest):
# def isSubstring(small, big):
# def allocate_tcp_port():
# def _make_socket():
# def ensure_tuple_str(input_tuple):
# def ensure_dict_binary(d):
# def ensure_dict_str(d):
# def ensure_dict_str_keys(d):
# FORMAT_TIME_MODES = ["short-local", "long-local", "utc", "epoch"]


# Path: src/foolscap/test/test_call.py
import gc
import re
import sys
    from twisted.python import log
from twisted.python import log
from twisted.trial import unittest
from twisted.internet.main import CONNECTION_LOST, CONNECTION_DONE
from twisted.python.failure import Failure
from twisted.application import service
from foolscap.tokens import Violation
from foolscap.eventual import flushEventualQueue
from foolscap.test.common import HelperTarget, TargetMixin, ShouldFailMixin
from foolscap.test.common import RIMyTarget, Target, TargetWithoutInterfaces, \
     BrokenTarget, MakeTubsMixin
from foolscap.api import RemoteException, DeadReferenceError
from foolscap.call import CopiedFailure
from foolscap.logging import log as flog
from ..util import long_type

        self.assertTrue(f.check(Violation))
        self.assertTrue(re.search(r'RIMyTarget\(.*\) does not offer bogus',
                                  str(f)))
        self.assertFalse(f.check(RemoteException))

    def _examine_remote_violation(self, r, should_be_remote):
        f = r[0]
        if should_be_remote:
            self.assertTrue(f.check(RemoteException))
            self.assertFalse(f.check(Violation))
            f2 = f.value.failure
        else:
            self.assertFalse(f.check(RemoteException))
            self.assertTrue(f.check(Violation))
            f2 = f
        self.assertTrue(isinstance(f2, CopiedFailure))
        self.assertTrue(f2.check(Violation))
        self.failUnlessSubstring("STRING token rejected by IntegerConstraint",
                                 f2.value)
        self.failUnlessSubstring("<RootUnslicer>.<methodcall", f2.value)
        self.failUnlessSubstring(" methodname=add", f2.value)
        self.failUnlessSubstring("<arguments arg[b]>", f2.value)
        self.assertFalse(f2.check(RemoteException))

    def _examine_remote_attribute_error(self, r, should_be_remote):
        f = r[0]
        if should_be_remote:
            self.assertTrue(f.check(RemoteException))
            self.assertFalse(f.check(AttributeError))
            f2 = f.value.failure

        else: