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,50 @@ 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 ("__pycache__/_virtualenv.cpython-313.pyc" ),
96+ File .new ("project_1.dist-info/RECORD" ),
97+ File .new ("project_1.dist-info/direct_url.json" , contents = json .dumps ({"url" : str (tmp_path )})),
98+ ]
9099 files = [
91100 File .new ("project_1/__init__.py" ),
92101 File .new ("project_1/project1.py" ),
102+ File .new ("project_1.dist-info/METADATA" ),
93103 File .new ("small_dependency/__init__.py" ),
94104 File .new ("small_dependency/small_dependency.py" , "# This is a small dependency" ),
105+ * files_excluded_from_bundle ,
95106 ]
96- data = Data .new (project_name = "project-1" , project_files = files ).commit (loc = tmp_path )
97- yield data
107+ yield files , files_excluded_from_bundle , tmp_path
98108
99109@pytest .fixture
100- def test_data_nested (tmp_path : Path ):
110+ def test_files_nested (test_files ):
111+ files , files_excluded_from_bundle , tmp_path = test_files
101112 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 ),
113+ * files ,
114+ * [
115+ File .new ("gigantic_dependency/__init__.py" ),
116+ File .new ("gigantic_dependency/gigantic.py" , "a" * Packager .AWS_LAMBDA_MAX_UNZIP_SIZE ),
117+ ],
108118 ]
109- data = Data .new (project_name = "project-1" , project_files = files ).commit (loc = tmp_path )
119+ yield files , files_excluded_from_bundle , tmp_path
120+
121+ @pytest .fixture
122+ def test_data (test_files ):
123+ files , files_excluded_from_bundle , loc = test_files
124+ data = Data .new (
125+ project_name = "project-1" ,
126+ project_files = files ,
127+ files_excluded_from_bundle = files_excluded_from_bundle ,
128+ ).commit (loc = loc )
129+ yield data
130+
131+ @pytest .fixture
132+ def test_data_nested (test_files_nested ):
133+ files , files_excluded_from_bundle , loc = test_files_nested
134+ data = Data .new (
135+ project_name = "project-1-nested" ,
136+ project_files = files ,
137+ files_excluded_from_bundle = files_excluded_from_bundle ,
138+ ).commit (loc = loc )
110139 yield data
0 commit comments