code: def should_reuse_driver(self, scope, test_passed, context=None):
          
          reuse_driver = self.config.getboolean_optional('Driver', 'reuse_driver')
          reuse_driver_session = self.config.getboolean_optional('Driver', 'reuse_driver_session')
          restart_driver_after_failure = (self.config.getboolean_optional('Driver', 'restart_driver_after_failure') or
                                          self.config.getboolean_optional('Driver', 'restart_driver_fail'))
          if context and scope == 'function':
              reuse_driver = reuse_driver or (hasattr(context, 'reuse_driver_from_tags')
                                              and context.reuse_driver_from_tags)
          return (((reuse_driver and scope == 'function') or (reuse_driver_session and scope != 'session'))
                  and (test_passed or not restart_driver_after_failure))
docs: Check if the driver should be reused
  
          :param scope: execution scope (function, module, class or session)
          :param test_passed: True if the test has passed
          :param context: behave context
          :returns: True if the driver should be reused