"""
Adapted from unittest2/loader.py from the unittest2 plugins branch.

This module contains some code copied from unittest2/loader.py and other
code developed in reference to that module and others within unittest2.

unittest2 is Copyright (c) 2001-2010 Python Software Foundation; All
Rights Reserved. See: http://docs.python.org/license.html

"""
import unittest

from nose2 import events


__unittest = True


class TestCaseLoader(events.Plugin):
    def __init__(self):
        # really always on!
        self.register()

    def loadTestsFromModule(self, event):
        """Load tests in unittest.TestCase subclasses"""
        module = event.module
        for name in dir(module):
            obj = getattr(module, name)
            if isinstance(obj, type) and issubclass(obj, unittest.TestCase):
                event.extraTests.append(self._loadTestsFromTestCase(event, obj))

    def _loadTestsFromTestCase(self, event, testCaseClass):
        evt = events.LoadFromTestCaseEvent(event.loader, testCaseClass)
        result = self.session.hooks.loadTestsFromTestCase(evt)
        if evt.handled:
            loaded_suite = result or event.loader.suiteClass()
        else:
            names = self._getTestCaseNames(event, testCaseClass)
            if not names and hasattr(testCaseClass, 'runTest'):
                names = ['runTest']
            # FIXME return failure test case if name not in testcase class
            loaded_suite = event.loader.suiteClass(map(testCaseClass, names))
        if evt.extraTests:
            loaded_suite.addTests(evt.extraTests)
        return loaded_suite

    def _getTestCaseNames(self, event, testCaseClass):
        excluded = set()
        def isTestMethod(attrname, testCaseClass=testCaseClass,
                         excluded=excluded):
            prefix = evt.testMethodPrefix or self.session.testMethodPrefix
            return (
                attrname.startswith(prefix) and
                hasattr(getattr(testCaseClass, attrname), '__call__') and
                attrname not in excluded
            )
        evt = events.GetTestCaseNamesEvent(
            event.loader, testCaseClass, isTestMethod)
        result = self.session.hooks.getTestCaseNames(evt)
        if evt.handled:
            test_names = result or []
        else:
            excluded = excluded.update(evt.excludedNames)
            test_names = [entry for entry in dir(testCaseClass)
                          if isTestMethod(entry)]
        if evt.extraNames:
            test_names.extend(evt.extraNames)
        if event.loader.sortTestMethodsUsing:
            test_names.sort(
                key=event.loader.sortTestMethodsUsing)
        return test_names

@@ -385,16 +385,22 @@
 t events
+, util
 %0A%0A%0A__uni
@@ -889,16 +889,541 @@
  obj))%0A%0A
+    def loadTestsFromName(self, event):%0A        name = event.name%0A        module = event.module%0A        result = util.test_from_name(name, module)%0A        if result is None:%0A            return%0A        parent, obj, name, index = result%0A        if isinstance(obj, type) and issubclass(obj, unittest.TestCase):%0A            event.extraTests.append(self._loadTestsFromTestCase(event, obj))%0A        elif isinstance(parent, type) and issubclass(parent, unittest.TestCase):%0A            event.extraTests.append(parent(obj.__name__))%0A%0A
     def 

Support loading from testcases by name