code: def monkey_patch_behave(django_test_runner):
      
      behave_run_hook = ModelRunner.run_hook
  
      def run_hook(self, name, context, *args):
          if name == 'before_all':
              django_test_runner.patch_context(context)
  
          behave_run_hook(self, name, context, *args)
  
          if name == 'before_scenario':
              django_test_runner.setup_testclass(context)
              django_test_runner.setup_fixtures(context)
              django_test_runner.setup_test(context)
              behave_run_hook(self, 'django_ready', context)
  
          if name == 'after_scenario':
              django_test_runner.teardown_test(context)
  
      ModelRunner.run_hook = run_hook
docs: Integrate behave_django in behave via before/after scenario hooks