HEX
Server: Apache/2.4.65 (Ubuntu)
System: Linux ielts-store-v2 6.8.0-1036-gcp #38~22.04.1-Ubuntu SMP Thu Aug 14 01:19:18 UTC 2025 x86_64
User: root (0)
PHP: 7.2.34-54+ubuntu20.04.1+deb.sury.org+1
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: //snap/google-cloud-cli/394/lib/third_party/dulwich/dulwich_test.py
#
# Copyright 2010 Google Inc. All Rights Reserved.

"""Tests for Dulwich.

This module is a stub that runs the builtin Dulwich test suite.
"""
from __future__ import print_function

import sys
import types
import unittest

from absl import flags
from dulwich import tests
from dulwich.tests import utils

if sys.version_info.major >= 3:
  from importlib import reload

# Hold on to the original unittest.TestCase. It is overwritten as a side effect
# of importing googletest, which breaks the default test runner.
_real_testcase = unittest.TestCase

from google3.devtools.git.common import (  # pylint: disable-msg=C6204
    git_test_util)

# We need googletest to define FLAGS.test_tmpdir
from google3.testing.pybase import googletest  # pylint: disable-msg=W0611

unittest.TestCase = _real_testcase

FLAGS = flags.FLAGS


def NonSkippingExtFunctestBuilder(method, func):
  """Alternate implementation of dulwich.tests.utils.ext_functest_builder.

  Dulwich skips extension tests for missing C extensions, but we need them in
  google3. This implementation fails fast if the C extensions are not found.

  Args:
    method: The method to run.
    func: The function implementation to pass to method.

  Returns:
    A test method to run the given C extension function.
  """

  def DoTest(self):
    self.assertTrue(isinstance(func, types.BuiltinFunctionType),
                    'C extension for %s not found' % func.__name__)
    method(self, func)

  return DoTest


# Replace Dulwich's ext_functest_builder with our implementation. This works
# because the test modules aren't loaded until test_suite() is called below.
utils.ext_functest_builder = NonSkippingExtFunctestBuilder


if __name__ == '__main__':
  print('ENCODING: ' + sys.getfilesystemencoding(), file=sys.stderr)
  reload(sys)
  sys.getfilesystemencoding = lambda: 'ascii'
  print('ENCODING: ' + sys.getfilesystemencoding(), file=sys.stderr)
  googletest.ThisTestIsUsefulWithoutCallingMain()
  result = unittest.TextTestRunner().run(tests.test_suite())
  sys.exit(not result.wasSuccessful())