<commit_before># Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Tests for clif.testing.python.smart_ptrs."""

from absl.testing import absltest
from absl.testing import parameterized

from clif.testing.python import smart_ptrs
# TODO: Restore simple import after OSS setup includes pybind11.
# pylint: disable=g-import-not-at-top
try:
  from clif.testing.python import smart_ptrs_pybind11
except ImportError:
  smart_ptrs_pybind11 = None
# pylint: enable=g-import-not-at-top


class Add(smart_ptrs.Operation):

  def __init__(self, a, b):
    smart_ptrs.Operation.__init__(self)
    self.a = a
    self.b = b

  def Run(self):
    return self.a + self.b


class AddPybind11(smart_ptrs_pybind11.Operation):

  def __init__(self, a, b):
    smart_ptrs_pybind11.Operation.__init__(self)
    self.a = a
    self.b = b

  def Run(self):
    return self.a + self.b


def AddParameterized(wrapper_lib):
  return AddPybind11 if wrapper_lib is smart_ptrs_pybind11 else Add


@parameterized.named_parameters([
    np for np in zip(('c_api', 'pybind11'), (smart_ptrs, smart_ptrs_pybind11))
    if np[1] is not None
])<commit_msg>Fixing smart_ptrs_test GitHub CI failure. ``` File "/clif/build/clif/testing/python/smart_ptrs_test.py", line 41, in <module>   class AddPybind11(smart_ptrs_pybind11.Operation): AttributeError: 'NoneType' object has no attribute 'Operation' ``` Tested locally by temporarily setting ``` smart_ptrs_pybind11 = None ``` after the `import` block.<commit_after># Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Tests for clif.testing.python.smart_ptrs."""

from absl.testing import absltest
from absl.testing import parameterized

from clif.testing.python import smart_ptrs
# TODO: Restore simple import after OSS setup includes pybind11.
# pylint: disable=g-import-not-at-top
try:
  from clif.testing.python import smart_ptrs_pybind11
except ImportError:
  smart_ptrs_pybind11 = None
# pylint: enable=g-import-not-at-top


class Add(smart_ptrs.Operation):

  def __init__(self, a, b):
    smart_ptrs.Operation.__init__(self)
    self.a = a
    self.b = b

  def Run(self):
    return self.a + self.b


class AddPybind11(object if smart_ptrs_pybind11 is None else
                  smart_ptrs_pybind11.Operation):

  def __init__(self, a, b):
    smart_ptrs_pybind11.Operation.__init__(self)
    self.a = a
    self.b = b

  def Run(self):
    return self.a + self.b


def AddParameterized(wrapper_lib):
  return AddPybind11 if wrapper_lib is smart_ptrs_pybind11 else Add


@parameterized.named_parameters([
    np for np in zip(('c_api', 'pybind11'), (smart_ptrs, smart_ptrs_pybind11))
    if np[1] is not None
])
{'fraction_non_alphanumeric': 0.0902683654106804, 'fraction_numerical': 0.018433179723502304, 'mean_word_length': 4.197183098591549, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7233903', 'n_tokens_mistral': 1210, 'n_tokens_neox': 1154, 'n_words': 388}