def setup(self): test_instance = self class MockBundle(Bundle): urls_to_fake = ['foo'] def __init__(self, *a, **kw): Bundle.__init__(self, *a, **kw) self.env = get_env() # Kind of hacky, but gives us access to the last Bundle # instance used by our Django template tag. test_instance.the_bundle = self def urls(self, *a, **kw): return self.urls_to_fake # Inject our mock bundle class self._old_bundle_class = AssetsNode.BundleClass AssetsNode.BundleClass = self.BundleClass = MockBundle # Reset the Django asset environment, init it with some # dummy bundles. django_env_reset() self.foo_bundle = Bundle() self.bar_bundle = Bundle() django_env_register('foo_bundle', self.foo_bundle) django_env_register('bar_bundle', self.bar_bundle)
def setup(self): test_instance = self class MockBundle(Bundle): urls_to_fake = ["foo"] def __init__(self, *a, **kw): Bundle.__init__(self, *a, **kw) self.env = get_env() # Kind of hacky, but gives us access to the last Bundle # instance used by our Django template tag. test_instance.the_bundle = self def urls(self, *a, **kw): return self.urls_to_fake # Inject our mock bundle class self._old_bundle_class = AssetsNode.BundleClass AssetsNode.BundleClass = self.BundleClass = MockBundle # Reset the Django asset environment, init it with some # dummy bundles. django_env_reset() self.foo_bundle = Bundle() self.bar_bundle = Bundle() django_env_register("foo_bundle", self.foo_bundle) django_env_register("bar_bundle", self.bar_bundle)