Skip to content

Commit 1876da3

Browse files
dmitriplotnikovcopybara-github
authored andcommitted
[Python] Fix wheel verification tests in cel_basic_test.py
1. Use `plain_value()` instead of `value()` when asserting the list result of `lists.range(3)` in `test_standard_extensions`, since `value()` returns a list of `_CelListItemAccessor` instances. 2. Exclude `cel_basic_test.py`'s directory from the `importlib.metadata.distributions` search path in `test_wheel_package_contents` so that `cibuildwheel` inspects the installed `.dist-info` wheel in `site-packages` rather than the build directory's `.egg-info`. PiperOrigin-RevId: 1015811456
1 parent 7f2d048 commit 1876da3

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

‎MODULE.bazel‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ bazel_dep(name = "bazel_skylib", version = "1.9.0")
1717

1818
# https://registry.bazel.build/modules/cel-cpp
1919
bazel_dep(name = "cel-cpp", version = "0.17.0", repo_name = "com_google_cel_cpp")
20+
git_override(
21+
module_name = "cel-cpp",
22+
commit = "9a6fd8ce1222209824c471306fa7f352faeff0d9",
23+
remote = "https://github.com/cel-expr/cel-cpp",
24+
)
2025

2126
# https://registry.bazel.build/modules/cel-spec
2227
bazel_dep(name = "cel-spec", version = "0.25.3", repo_name = "com_google_cel_spec")

‎release/cel_basic_test.py‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
"""Basic tests for cel-python."""
1616

1717
import importlib.metadata
18+
import os
19+
import sys
1820
import unittest
1921

2022
from cel_expr_python import cel
@@ -64,7 +66,7 @@ def test_standard_extensions(self):
6466

6567
# Test lists
6668
expr = env.compile("lists.range(3)")
67-
self.assertEqual(expr.eval().value(), [0, 1, 2])
69+
self.assertEqual(expr.eval().plain_value(), [0, 1, 2])
6870

6971
# Test math
7072
expr = env.compile("math.greatest(1, 5, 3)")
@@ -125,7 +127,22 @@ def test_custom_extension(self):
125127
self.assertEqual(res.value(), "Hello, world! Hi, CEL!")
126128

127129
def test_wheel_package_contents(self):
128-
dist = importlib.metadata.distribution("cel-expr-python")
130+
# Exclude the script's own directory (which may be the build directory
131+
# containing a source `.egg-info`) so we inspect the installed wheel's
132+
# `.dist-info` distribution in site-packages.
133+
script_dir = os.path.realpath(os.path.dirname(os.path.abspath(__file__)))
134+
search_paths = [
135+
p for p in sys.path if p and os.path.realpath(p) != script_dir
136+
]
137+
dists = list(
138+
importlib.metadata.distributions(
139+
name="cel-expr-python", path=search_paths
140+
)
141+
)
142+
self.assertTrue(
143+
dists, "Could not find installed cel-expr-python distribution"
144+
)
145+
dist = dists[0]
129146
top_level = dist.read_text("top_level.txt")
130147
if top_level is not None:
131148
self.assertEqual(top_level.strip().splitlines(), ["cel_expr_python"])

0 commit comments

Comments
 (0)