# Path: oslo_utils/importutils.py
# def import_class(import_str):
# def import_object(import_str, *args, **kwargs):
# def import_object_ns(name_space, import_str, *args, **kwargs):
# def import_module(import_str):
# def import_versioned_module(module, version, submodule=None):
# def try_import(import_str, default=None):
# def import_any(module, *modules):


import datetime
import sys
from oslotest import base as test_base
from oslo_utils import importutils
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.





class ImportUtilsTest(test_base.BaseTestCase):

    # NOTE(jkoelker) There has GOT to be a way to test this. But mocking
    #                __import__ is the devil. Right now we just make
    #               sure we can import something from the stdlib
    def test_import_class(self):
        dt = importutils.import_class('datetime.datetime')
        self.assertEqual(sys.modules['datetime'].datetime, dt)

    def test_import_bad_class(self):
        self.assertRaises(ImportError, importutils.import_class,
                          'lol.u_mad.brah')

    def test_import_module(self):
        dt = importutils.import_module('datetime')

# Path: oslo_utils/importutils.py
# def import_class(import_str):
# def import_object(import_str, *args, **kwargs):
# def import_object_ns(name_space, import_str, *args, **kwargs):
# def import_module(import_str):
# def import_versioned_module(module, version, submodule=None):
# def try_import(import_str, default=None):
# def import_any(module, *modules):


# Path: oslo_utils/tests/test_importutils.py
import datetime
import sys
from oslotest import base as test_base
from oslo_utils import importutils

#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.





class ImportUtilsTest(test_base.BaseTestCase):

    # NOTE(jkoelker) There has GOT to be a way to test this. But mocking
    #                __import__ is the devil. Right now we just make
    #               sure we can import something from the stdlib
    def test_import_class(self):
        dt = importutils.import_class('datetime.datetime')
        self.assertEqual(sys.modules['datetime'].datetime, dt)

    def test_import_bad_class(self):
        self.assertRaises(ImportError, importutils.import_class,
                          'lol.u_mad.brah')

    def test_import_module(self):
        dt = importutils.import_module('datetime')

        self.assertEqual(sys.modules['datetime'], dt)