示例#1
0
 def _init_fixups(self) -> MutableSequence[FixupT]:
     # Returns list of "fixups"
     # Fixups are small additional patches we apply when certain
     # platforms or frameworks are present.
     #
     # One example is the Django fixup, responsible for Django integration
     # whenever the DJANGO_SETTINGS_MODULE environment variable is
     # set. See faust/fixups/django.py, it's not complicated - using
     # setuptools entrypoints you can very easily create extensions that
     # are automatically enabled by installing a PyPI package with
     # `pip install myname`.
     return list(fixups(self))
示例#2
0
 def test_fixup_env_enabled_no_django(self, *, app, fixup, monkeypatch):
     monkeypatch.setenv("DJANGO_SETTINGS_MODULE", "settings")
     with mask_module("django"):
         with pytest.warns(UserWarning):
             assert not fixup.enabled()
             assert not any(isinstance(f, Fixup) for f in fixups(app))
示例#3
0
 def test_fixup_env_disabled(self, *, app, fixup, monkeypatch):
     monkeypatch.delenv("DJANGO_SETTINGS_MODULE", raising=False)
     assert not fixup.enabled()
     assert not any(isinstance(f, Fixup) for f in fixups(app))
示例#4
0
 def test_fixup_env_enabled(self, *, app, fixup, monkeypatch):
     monkeypatch.setenv("DJANGO_SETTINGS_MODULE", "settings")
     with patch_module("django"):
         assert fixup.enabled()
         assert any(isinstance(f, Fixup) for f in fixups(app))