Exemple #1
0
    def __init__(self, matcher, target, target_kwargs=None, name=None):
        """Constructs a Rule instance.

        :arg Matcher matcher: a `Matcher` instance used for determining
            whether the rule should be considered a match for a specific
            request.
        :arg target: a Rule's target (typically a ``RequestHandler`` or
            `~.httputil.HTTPServerConnectionDelegate` subclass or even a nested `Router`,
            depending on routing implementation).
        :arg dict target_kwargs: a dict of parameters that can be useful
            at the moment of target instantiation (for example, ``status_code``
            for a ``RequestHandler`` subclass). They end up in
            ``target_params['target_kwargs']`` of `RuleRouter.get_target_delegate`
            method.
        :arg str name: the name of the rule that can be used to find it
            in `ReversibleRouter.reverse_url` implementation.
        """
        if isinstance(target, str):
            # import the Module and instantiate the class
            # Must be a fully qualified name (module.ClassName)
            target = import_object(target)

        self.matcher = matcher  # type: Matcher
        self.target = target
        self.target_kwargs = target_kwargs if target_kwargs else {}
        self.name = name
Exemple #2
0
 def test_import_module_unicode(self):
     # The internal implementation of __import__ differs depending on
     # whether the thing being imported is a module or not.
     # This variant requires a byte string in python 2.
     self.assertIs(import_object(u'tornado.escape'), salt.ext.tornado.escape)
Exemple #3
0
 def test_import_member_unicode(self):
     self.assertIs(import_object(u'tornado.escape.utf8'), utf8)
Exemple #4
0
 def test_import_module(self):
     self.assertIs(import_object('tornado.escape'), salt.ext.tornado.escape)
Exemple #5
0
            'test_listenOnLinuxAbstractNamespace',
        ],
        'twisted.internet.test.test_unix.UNIXPortTestsBuilder': [],
    }
    if sys.version_info >= (3, ):
        # In Twisted 15.2.0 on Python 3.4, the process tests will try to run
        # but fail, due in part to interactions between Tornado's strict
        # warnings-as-errors policy and Twisted's own warning handling
        # (it was not obvious how to configure the warnings module to
        # reconcile the two), and partly due to what looks like a packaging
        # error (process_cli.py missing). For now, just skip it.
        del twisted_tests[
            'twisted.internet.test.test_process.ProcessTestsBuilder']
    for test_name, blacklist in twisted_tests.items():
        try:
            test_class = import_object(test_name)
        except (ImportError, AttributeError):
            continue
        for test_func in blacklist:  # type: ignore
            if hasattr(test_class, test_func):
                # The test_func may be defined in a mixin, so clobber
                # it instead of delattr()
                setattr(test_class, test_func, lambda self: None)

        def make_test_subclass(test_class):
            class TornadoTest(test_class):  # type: ignore
                _reactors = ["tornado.platform.twisted._TestReactor"]

                def setUp(self):
                    # Twisted's tests expect to be run from a temporary
                    # directory; they create files in their working directory