From e2d90e5bac6f12b2f22213195eff3230b537f8a4 Mon Sep 17 00:00:00 2001 From: Chris Novakovic Date: Mon, 10 Aug 2026 16:41:39 +0100 Subject: [PATCH] Add `PexDistribution` resources test This new test ensures that `importlib.resources` can be used to read files in a distribution inside a .pex file via `PexDistribution`. --- test/BUILD | 8 ++++++++ test/resources_test.py | 12 ++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 test/resources_test.py diff --git a/test/BUILD b/test/BUILD index dfdc610f..d12cad3f 100644 --- a/test/BUILD +++ b/test/BUILD @@ -172,6 +172,14 @@ python_test( ], ) +python_test( + name = "resources_test", + srcs = ["resources_test.py"], + deps = [ + "//third_party/python:pygments", + ], +) + python_test( name = "interpreter_not_included_test", srcs = ["interpreter_not_included_test.py"], diff --git a/test/resources_test.py b/test/resources_test.py new file mode 100644 index 00000000..ec75e50f --- /dev/null +++ b/test/resources_test.py @@ -0,0 +1,12 @@ +import importlib.resources +import unittest + + +class ResourcesTest(unittest.TestCase): + """Tests that PexDistribution is able to provide access to files that are part of a distribution + via the importlib.resources API. + """ + + def test_read_resource_text_file(self): + init = importlib.resources.files("pygments") / "__init__.py" + self.assertIn("__version__ = '2.19.2'", init.read_text())