blob: 17c1541f086e542d2673afb0cf6889d94b71affd [file] [log] [blame]
# Copyright 2023 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import pathlib
import platform
import sys
import unittest
PYTHON_VERSION = "3.11.4"
class Py3Test(unittest.TestCase):
def test_version(self):
self.assertEqual(platform.python_version(), PYTHON_VERSION)
def test_interpreter(self):
self.assertIn("python3_test.runfiles", sys.executable)
def test_no_implicit_system_deps(self):
with self.assertRaises(ImportError):
import pylint
def test_no_implicit_directory_deps(self):
with self.assertRaises(ImportError):
import pip_test
def test_hermetic_path(self):
for path in sys.path:
self.assertIn("/execroot/_main/", path)
def test_runfiles(self):
from python.runfiles import runfiles
r = runfiles.Create()
path = pathlib.Path(
r.Rlocation("cros/bazel/python/testdata/example.txt")
)
self.assertTrue(path.is_file())
def test_import_from_repo_rule(self):
# sitecustomize.py should do the repo mapping for us.
from rules_python.python.runfiles import runfiles
if __name__ == "__main__":
unittest.main()