1+ import json
12from dataclasses import dataclass
23from pathlib import Path
34from typing import Self
@@ -24,6 +25,7 @@ def new(cls, path: str, contents: str = "") -> Self:
2425
2526@dataclass
2627class Data :
28+ files_excluded_from_bundle : list [File ] # relative to packages_dir
2729 project_files : list [File ] # relative to packages_dir
2830 pyproject : PythonProject
2931 python_version : str
@@ -34,10 +36,12 @@ def new(
3436 cls ,
3537 project_name : str ,
3638 project_files : list [File ],
39+ files_excluded_from_bundle : list [File ],
3740 python_version : str = "3.13" ,
3841 ) -> Self :
3942 pyproject = _new_python_project (name = project_name )
4043 return cls (
44+ files_excluded_from_bundle = files_excluded_from_bundle ,
4145 project_files = project_files ,
4246 pyproject = pyproject ,
4347 python_version = python_version ,
@@ -86,25 +90,49 @@ def verify_file_reproducibility(file_info: list[ZipInfo], expected_file_date_tim
8690 assert info .date_time == expected_file_date_time
8791
8892@pytest .fixture
89- def test_data (tmp_path : Path ):
93+ def test_files (tmp_path : Path ):
94+ files_excluded_from_bundle = [
95+ File .new ("project_1.dist-info/RECORD" ),
96+ File .new ("project_1.dist-info/direct_url.json" , contents = json .dumps ({"url" : str (tmp_path )})),
97+ ]
9098 files = [
9199 File .new ("project_1/__init__.py" ),
92100 File .new ("project_1/project1.py" ),
101+ File .new ("project_1.dist-info/METADATA" ),
93102 File .new ("small_dependency/__init__.py" ),
94103 File .new ("small_dependency/small_dependency.py" , "# This is a small dependency" ),
104+ * files_excluded_from_bundle ,
95105 ]
96- data = Data .new (project_name = "project-1" , project_files = files ).commit (loc = tmp_path )
97- yield data
106+ yield files , files_excluded_from_bundle , tmp_path
98107
99108@pytest .fixture
100- def test_data_nested (tmp_path : Path ):
109+ def test_files_nested (test_files ):
110+ files , files_excluded_from_bundle , tmp_path = test_files
101111 files = [
102- File .new ("project_1/__init__.py" ),
103- File .new ("project_1/project1.py" ),
104- File .new ("small_dependency/__init__.py" ),
105- File .new ("small_dependency/small_dependency.py" , "# This is a small dependency" ),
106- File .new ("gigantic_dependency/__init__.py" ),
107- File .new ("gigantic_dependency/gigantic.py" , "a" * Packager .AWS_LAMBDA_MAX_UNZIP_SIZE ),
112+ * files ,
113+ * [
114+ File .new ("gigantic_dependency/__init__.py" ),
115+ File .new ("gigantic_dependency/gigantic.py" , "a" * Packager .AWS_LAMBDA_MAX_UNZIP_SIZE ),
116+ ],
108117 ]
109- data = Data .new (project_name = "project-1" , project_files = files ).commit (loc = tmp_path )
118+ yield files , files_excluded_from_bundle , tmp_path
119+
120+ @pytest .fixture
121+ def test_data (test_files ):
122+ files , files_excluded_from_bundle , loc = test_files
123+ data = Data .new (
124+ project_name = "project-1" ,
125+ project_files = files ,
126+ files_excluded_from_bundle = files_excluded_from_bundle ,
127+ ).commit (loc = loc )
128+ yield data
129+
130+ @pytest .fixture
131+ def test_data_nested (test_files_nested ):
132+ files , files_excluded_from_bundle , loc = test_files_nested
133+ data = Data .new (
134+ project_name = "project-1-nested" ,
135+ project_files = files ,
136+ files_excluded_from_bundle = files_excluded_from_bundle ,
137+ ).commit (loc = loc )
110138 yield data
0 commit comments