Exemple #1
0
 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')
Exemple #2
0
 def test_repr(self):
     ac = AppConfig('label', Stub(__path__=['a']))
     self.assertEqual(repr(ac), '<AppConfig: label>')
Exemple #3
0
 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__=[]))
Exemple #4
0
 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']))
Exemple #5
0
 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())
Exemple #6
0
    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')
Exemple #7
0
    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')
Exemple #8
0
    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')
Exemple #9
0
    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')