django.apps.AppConfig

Here are the examples of the python api django.apps.AppConfig taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

9 Examples 7

3 Source : tests.py
with Apache License 2.0
from gethue

    def test_dunder_path(self):
        """If single element in __path__, use it (in preference to __file__)."""
        ac = AppConfig('label', Stub(__path__=['a'], __file__='b/__init__.py'))

        self.assertEqual(ac.path, 'a')

    def test_no_dunder_path_fallback_to_dunder_file(self):

3 Source : tests.py
with Apache License 2.0
from gethue

    def test_no_dunder_path_fallback_to_dunder_file(self):
        """If there is no __path__ attr, use __file__."""
        ac = AppConfig('label', Stub(__file__='b/__init__.py'))

        self.assertEqual(ac.path, 'b')

    def test_empty_dunder_path_fallback_to_dunder_file(self):

3 Source : tests.py
with Apache License 2.0
from gethue

    def test_empty_dunder_path_fallback_to_dunder_file(self):
        """If the __path__ attr is empty, use __file__ if set."""
        ac = AppConfig('label', Stub(__path__=[], __file__='b/__init__.py'))

        self.assertEqual(ac.path, 'b')

    def test_multiple_dunder_path_fallback_to_dunder_file(self):

3 Source : tests.py
with Apache License 2.0
from gethue

    def test_multiple_dunder_path_fallback_to_dunder_file(self):
        """If the __path__ attr is length>1, use __file__ if set."""
        ac = AppConfig('label', Stub(__path__=['a', 'b'], __file__='c/__init__.py'))

        self.assertEqual(ac.path, 'c')

    def test_no_dunder_path_or_dunder_file(self):

3 Source : tests.py
with Apache License 2.0
from gethue

    def test_no_dunder_path_or_dunder_file(self):
        """If there is no __path__ or __file__, raise ImproperlyConfigured."""
        with self.assertRaises(ImproperlyConfigured):
            AppConfig('label', Stub())

    def test_empty_dunder_path_no_dunder_file(self):

3 Source : tests.py
with Apache License 2.0
from gethue

    def test_empty_dunder_path_no_dunder_file(self):
        """If the __path__ attr is empty and there is no __file__, raise."""
        with self.assertRaises(ImproperlyConfigured):
            AppConfig('label', Stub(__path__=[]))

    def test_multiple_dunder_path_no_dunder_file(self):

3 Source : tests.py
with Apache License 2.0
from gethue

    def test_multiple_dunder_path_no_dunder_file(self):
        """If the __path__ attr is length>1 and there is no __file__, raise."""
        with self.assertRaises(ImproperlyConfigured):
            AppConfig('label', Stub(__path__=['a', 'b']))

    def test_duplicate_dunder_path_no_dunder_file(self):

3 Source : tests.py
with Apache License 2.0
from gethue

    def test_duplicate_dunder_path_no_dunder_file(self):
        """
        If the __path__ attr contains duplicate paths and there is no
        __file__, they duplicates should be deduplicated (#25246).
        """
        ac = AppConfig('label', Stub(__path__=['a', 'a']))
        self.assertEqual(ac.path, 'a')


@skipUnless(six.PY3, "Namespace packages sans __init__.py were added in Python 3.3")

3 Source : django-tests-i18n-tests.py
with Apache License 2.0
from SMAT-Lab

    def test_check_for_language(self):
        with tempfile.TemporaryDirectory() as app_dir:
            os.makedirs(os.path.join(app_dir, 'locale', 'dummy_Lang', 'LC_MESSAGES'))
            open(os.path.join(app_dir, 'locale', 'dummy_Lang', 'LC_MESSAGES', 'django.mo'), 'w').close()
            app_config = AppConfig('dummy_app', AppModuleStub(__path__=[app_dir]))
            with mock.patch('django.apps.apps.get_app_configs', return_value=[app_config]):
                self.assertIs(check_for_language('dummy-lang'), True)

    @override_settings(