Skip to content

Commit 10e98d1

Browse files
committed
ok robot
1 parent 212a795 commit 10e98d1

2 files changed

Lines changed: 32 additions & 35 deletions

File tree

gazelle/modules_mapping/def.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def _modules_mapping_impl(ctx):
3333
# Run the generator once per-wheel (to leverage caching)
3434
per_wheel_outputs = []
3535
for idx, whl in enumerate(all_wheels.to_list()):
36-
wheel_modules_mapping = ctx.actions.declare_file("modules_mapping_{}_{}".format(idx, ctx.attr.modules_mapping_name))
36+
wheel_modules_mapping = ctx.actions.declare_file("{}.{}".format(modules_mapping.short_path, idx))
3737
args = ctx.actions.args()
3838
args.add("--output_file", wheel_modules_mapping.path)
3939
if ctx.attr.include_stub_packages:

gazelle/modules_mapping/test_merger.py

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,37 @@
88

99
class MergerTest(unittest.TestCase):
1010
def test_merger(self):
11-
file1 = tempfile.NamedTemporaryFile("w")
12-
json.dump(
13-
{
14-
"_pytest": "pytest",
15-
"_pytest.__init__": "pytest",
16-
"_pytest._argcomplete": "pytest",
17-
"_pytest.config.argparsing": "pytest",
18-
},
19-
file1,
20-
)
21-
file1.flush()
22-
file2 = tempfile.NamedTemporaryFile("w")
23-
json.dump(
24-
{"django_types": "django_types"},
25-
file2,
26-
)
27-
file2.flush()
28-
output_file = tempfile.NamedTemporaryFile("r")
29-
30-
merge_modules_mappings(
31-
[pathlib.Path(file1.name), pathlib.Path(file2.name)],
32-
pathlib.Path(output_file.name),
33-
)
34-
35-
self.assertEqual(
36-
{
37-
"_pytest": "pytest",
38-
"_pytest.__init__": "pytest",
39-
"_pytest._argcomplete": "pytest",
40-
"_pytest.config.argparsing": "pytest",
41-
"django_types": "django_types",
42-
},
43-
json.load(output_file),
44-
)
11+
with tempfile.TemporaryDirectory() as tmpdir:
12+
d = pathlib.Path(tmpdir)
13+
path1 = d / "file1.json"
14+
path2 = d / "file2.json"
15+
output_path = d / "output.json"
16+
17+
path1.write_text(
18+
json.dumps(
19+
{
20+
"_pytest": "pytest",
21+
"_pytest.__init__": "pytest",
22+
"_pytest._argcomplete": "pytest",
23+
"_pytest.config.argparsing": "pytest",
24+
}
25+
)
26+
)
27+
28+
path2.write_text(json.dumps({"django_types": "django_types"}))
29+
30+
merge_modules_mappings([path1, path2], output_path)
31+
32+
self.assertEqual(
33+
{
34+
"_pytest": "pytest",
35+
"_pytest.__init__": "pytest",
36+
"_pytest._argcomplete": "pytest",
37+
"_pytest.config.argparsing": "pytest",
38+
"django_types": "django_types",
39+
},
40+
json.loads(output_path.read_text()),
41+
)
4542

4643

4744
if __name__ == "__main__":

0 commit comments

Comments
 (0)