Skip to content

Commit

Permalink
Import google/pybind11k from GitHub (google/pybind11clif#30117).
Browse files Browse the repository at this point in the history
This update needs corresponding changes in third_party/clif/testing/python/t3_test.py

TGP-tested via child CL: http://tap/OCL:626240839:BASE:626375750:1713541129757:e746a257

Note: Currently codesearch finds matches for `pybind11 native_enum` only in third_party/pybind11 and third_party/clif/pybind11.

This CL fixes 12 PyCLIF-pybind11 TGP failures: b/287289622#comment72

#MIGRATION_3P_PYBIND11__DEFAULT

  - e10cb7ec5d7091a817ed0f6a40f4d9f155c644c5 Fix `native_enum` `__module__` attribute: it needs to be ... by Ralf W. Grosse-Kunstleve <[email protected]>

PiperOrigin-RevId: 626400273
  • Loading branch information
rwgk committed Aug 27, 2024
1 parent 30cd8c5 commit d67cef2
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions clif/testing/python/t3_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@

"""Tests for clif.testing.python.t3."""

import pickle
import sys

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

from clif.testing.python import t3


class T3Test(absltest.TestCase):
class T3Test(parameterized.TestCase):

def testEnumBasic(self):
self.assertEqual(t3._Old.TOP1, 1)
Expand All @@ -37,12 +39,16 @@ def testEnumBasic(self):

def testEnumModuleName(self):
# This is necessary for proper pickling.
if t3.__pyclif_codegen_mode__ == 'pybind11':
self.assertEqual(t3._Old.__module__.__name__, t3.__name__)
self.assertEqual(t3._New.__module__.__name__, t3.__name__)
else:
self.assertEqual(t3._Old.__module__, t3.__name__)
self.assertEqual(t3._New.__module__, t3.__name__)
self.assertEqual(t3._Old.__module__, t3.__name__)
self.assertEqual(t3._New.__module__, t3.__name__)

@parameterized.parameters(
t3._Old.TOP1, t3._Old.TOPn, t3._New.TOP, t3._New.BOTTOM
)
def testPickleRoundtrip(self, orig):
serialized = pickle.dumps(orig)
restored = pickle.loads(serialized)
self.assertEqual(restored, orig)

def testEnumBases(self):
old_bases = t3._Old.__bases__
Expand Down

0 comments on commit d67cef2

Please sign in to comment.