# Path: gap/utils/tests.py
# class TestBase(TestCase):
# 
#     testbed = None
# 
#     _gae_stubs = setup.DEFAULT_TESTBEDS
# 
#     # Allow to share the setUpClass method among all parallel test classes
#     _multiprocess_shared_ = True
# 
#     # Allow concurrent run of fixtures
#     _multiprocess_can_split_ = True
# 
#     @classmethod
#     def setUpClass(cls):
#         # Begin with testbed instance
#         cls.testbed = setup.setup_testbed(stubs=cls._gae_stubs)
#         import app
# 
#     @classmethod
#     def tearDownClass(cls):
#         cls.testbed.deactivate()
# 
#     @staticmethod
#     def login(email, admin=False, user_id=None):
#         from os import environ as env
#         env['USER_EMAIL'] = email
#         env['USER_ID'] = user_id if user_id is not None else ''
#         env['USER_IS_ADMIN'] = str(int(admin))
#         # env = getattr(self, 'env', {})
#         # self.env = env
# 
#     @staticmethod
#     def logout():
#         from os import environ as env
#         for name in 'USER_EMAIL', 'USER_ID', 'USER_IS_ADMIN':
#             env[name] = ''
# 
# Path: gap/utils/imports.py
# def import_class(class_name):
#     """
#     imports and returns class by its path
# 
#     USAGE:
#         myclass = import_class('StringIO.StringIO')
#         # or
#         from StringIO import StringIO
#         myclass = import_class(StringIO)
#     """
#     if isinstance(class_name, StringTypes):
#         from importlib import import_module
#         module_name, class_name = class_name.rsplit('.', 1)
#         module = import_module(module_name)
#         return getattr(module, class_name)
#     else:
#         return class_name


from gap.utils.tests import TestBase
from gap.utils.imports import import_class
        from datetime import timedelta



class TestUtils(TestBase):

    def test_import_class_from_instance(self):
        """ import_class - importing class type from usage """
        timedelta_class = import_class('datetime.timedelta')
        self.assertEqual(type(timedelta()), timedelta_class)

# Path: gap/utils/tests.py
# class TestBase(TestCase):
# 
#     testbed = None
# 
#     _gae_stubs = setup.DEFAULT_TESTBEDS
# 
#     # Allow to share the setUpClass method among all parallel test classes
#     _multiprocess_shared_ = True
# 
#     # Allow concurrent run of fixtures
#     _multiprocess_can_split_ = True
# 
#     @classmethod
#     def setUpClass(cls):
#         # Begin with testbed instance
#         cls.testbed = setup.setup_testbed(stubs=cls._gae_stubs)
#         import app
# 
#     @classmethod
#     def tearDownClass(cls):
#         cls.testbed.deactivate()
# 
#     @staticmethod
#     def login(email, admin=False, user_id=None):
#         from os import environ as env
#         env['USER_EMAIL'] = email
#         env['USER_ID'] = user_id if user_id is not None else ''
#         env['USER_IS_ADMIN'] = str(int(admin))
#         # env = getattr(self, 'env', {})
#         # self.env = env
# 
#     @staticmethod
#     def logout():
#         from os import environ as env
#         for name in 'USER_EMAIL', 'USER_ID', 'USER_IS_ADMIN':
#             env[name] = ''
# 
# Path: gap/utils/imports.py
# def import_class(class_name):
#     """
#     imports and returns class by its path
# 
#     USAGE:
#         myclass = import_class('StringIO.StringIO')
#         # or
#         from StringIO import StringIO
#         myclass = import_class(StringIO)
#     """
#     if isinstance(class_name, StringTypes):
#         from importlib import import_module
#         module_name, class_name = class_name.rsplit('.', 1)
#         module = import_module(module_name)
#         return getattr(module, class_name)
#     else:
#         return class_name


# Path: gap/tests/test_imports.py
from gap.utils.tests import TestBase
from gap.utils.imports import import_class
        from datetime import timedelta




class TestUtils(TestBase):

    def test_import_class_from_instance(self):
        """ import_class - importing class type from usage """
        timedelta_class = import_class('datetime.timedelta')
        self.assertEqual(type(timedelta()), timedelta_class)

        self.assertEqual(type(timedelta()), import_class(timedelta))