def test_is_django_path(self): for module, expected in ( (pytz.__file__, False), (contextlib.__file__, False), (autoreload.__file__, True) ): with self.subTest(module=module): self.assertIs(autoreload.is_django_path(module), expected)
def get_template_directories(): # Iterate through each template backend and find # any template_loader that has a 'get_dirs' method. # Collect the directories, filtering out Django templates. items = set() for backend in engines.all(): if not isinstance(backend, DjangoTemplates): continue items.update(backend.engine.dirs) for loader in backend.engine.template_loaders: if not hasattr(loader, 'get_dirs'): continue items.update(directory for directory in loader.get_dirs() if not is_django_path(directory)) return items