Skip to content

Commit 8c9e03a

Browse files
committed
add tests
1 parent 24013ce commit 8c9e03a

File tree

14 files changed

+65
-0
lines changed

14 files changed

+65
-0
lines changed

MODULE.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ internal_dev_deps = use_extension(
102102
use_repo(
103103
internal_dev_deps,
104104
"buildkite_config",
105+
"implicit_namespace_ns_sub1",
106+
"implicit_namespace_ns_sub2",
105107
"rules_python_runtime_env_tc_info",
106108
"somepkg_with_build_files",
107109
"whl_with_build_files",

python/private/internal_dev_deps.bzl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def _internal_dev_deps_impl(mctx):
3030
)
3131
runtime_env_repo(name = "rules_python_runtime_env_tc_info")
3232

33+
# Setup for //tests/whl_with_build_files
3334
whl_from_dir_repo(
3435
name = "whl_with_build_files",
3536
root = "//tests/whl_with_build_files:testdata/BUILD.bazel",
@@ -41,6 +42,31 @@ def _internal_dev_deps_impl(mctx):
4142
requirement = "somepkg",
4243
)
4344

45+
# Setup for //tests/implicit_namespace_packages
46+
whl_from_dir_repo(
47+
name = "implicit_namespace_ns_sub1_whl",
48+
root = "//tests/implicit_namespace_packages:testdata/ns-sub1/BUILD.bazel",
49+
output = "ns_sub1-1.0-any-none-any.whl",
50+
)
51+
whl_library(
52+
name = "implicit_namespace_ns_sub1",
53+
whl_file = "@implicit_namespace_ns_sub1_whl//:ns_sub1-1.0-any-none-any.whl",
54+
requirement = "ns-sub1",
55+
enable_implicit_namespace_pkgs = False,
56+
)
57+
58+
whl_from_dir_repo(
59+
name = "implicit_namespace_ns_sub2_whl",
60+
root = "//tests/implicit_namespace_packages:testdata/ns-sub2/BUILD.bazel",
61+
output = "ns_sub2-1.0-any-none-any.whl",
62+
)
63+
whl_library(
64+
name = "implicit_namespace_ns_sub2",
65+
whl_file = "@implicit_namespace_ns_sub2_whl//:ns_sub2-1.0-any-none-any.whl",
66+
requirement = "ns-sub2",
67+
enable_implicit_namespace_pkgs = False,
68+
)
69+
4470
internal_dev_deps = module_extension(
4571
implementation = _internal_dev_deps_impl,
4672
doc = "This extension creates internal rules_python dev dependencies.",
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
load("//python:py_test.bzl", "py_test")
2+
3+
py_test(
4+
name = "namespace_packages_test",
5+
srcs = ["namespace_packages_test.py"],
6+
deps = [
7+
"@implicit_namespace_ns_sub1//:pkg",
8+
"@implicit_namespace_ns_sub2//:pkg",
9+
],
10+
)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
import unittest
3+
4+
class NamespacePackagesTest(unittest.TestCase):
5+
6+
def test_both_importable(self):
7+
import nspkg
8+
import nspkg.subpkg1
9+
import nspkg.subpkg1.subpkgmod
10+
11+
import nspkg.subpkg1
12+
import nspkg.subpkg2.subpkgmod
13+
14+
self.assertEqual("nspkg.subpkg1", nspkg.subpkg1.expected_name)
15+
self.assertEqual("nspkg.subpkg1.subpkgmod", nspkg.subpkg1.subpkgmod.expected_name)
16+
17+
self.assertEqual("nspkg.subpkg2", nspkg.subpkg2.expected_name)
18+
self.assertEqual("nspkg.subpkg2.subpkgmod", nspkg.subpkg2.subpkgmod.expected_name)
19+
20+
if __name__ == "__main__":
21+
unittest.main()

tests/implicit_namespace_packages/testdata/ns-sub1/ns-sub1-1.0.dist-info/METADATA

Whitespace-only changes.

tests/implicit_namespace_packages/testdata/ns-sub1/ns-sub1-1.0.dist-info/RECORD

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Wheel-Version: 1.0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
expected_name = "nspkg.subpkg1"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
expected_name = "nspkg.subpkg1.subpkgmod"

tests/implicit_namespace_packages/testdata/ns-sub2/ns_sub2-1.0.dist-info/METADATA

Whitespace-only changes.

0 commit comments

Comments
 (0)