@@ -54,6 +54,14 @@ def compare_file(filename, dir1, dir2):
5454 'dockerfile_python_version' : '' ,
5555 'has_requirements_txt' : False ,
5656 'entrypoint' : '' ,
57+ 'is_python_compat' : False ,
58+ }),
59+ ('env: flex\n runtime: python-compat' , {
60+ 'base_image' : None ,
61+ 'dockerfile_python_version' : None ,
62+ 'has_requirements_txt' : None ,
63+ 'entrypoint' : None ,
64+ 'is_python_compat' : True ,
5765 }),
5866 # All supported python versions
5967 ('runtime_config:\n python_version:' , {
@@ -125,7 +133,8 @@ def test_get_app_config_invalid(app_yaml):
125133 base_image = '' ,
126134 dockerfile_python_version = '' ,
127135 entrypoint = '' ,
128- has_requirements_txt = False
136+ has_requirements_txt = False ,
137+ is_python_compat = False ,
129138)
130139
131140
@@ -146,6 +155,9 @@ def test_get_app_config_invalid(app_yaml):
146155 # Python version
147156 (_BASE_APP_CONFIG ._replace (dockerfile_python_version = '_my_version' ), True ,
148157 'python_version=python_my_version' ),
158+ # python-compat runtime
159+ (_BASE_APP_CONFIG ._replace (is_python_compat = True ), True ,
160+ 'FROM gcr.io/google_appengine/python-compat-multicore' ),
149161])
150162def test_generate_files (app_config , should_find , test_string ):
151163 result = gen_dockerfile .generate_files (app_config )
@@ -163,10 +175,13 @@ def compare_against_golden_files(app, config_dir, testdata_dir):
163175 compare_file (filename , config_dir , golden_dir )
164176
165177
166- def test_generate_dockerfile_command (tmpdir , testdata_dir ):
178+ @pytest .mark .parametrize ('app' , [
179+ # Sampled from https://github.com/GoogleCloudPlatform/python-docs-samples
180+ 'hello_world' ,
181+ # From an internal source.
182+ 'hello_world_compat' ])
183+ def test_generate_dockerfile_command (tmpdir , testdata_dir , app ):
167184 """Generates output and compares against a set of golden files."""
168- # Sample from https://github.com/GoogleCloudPlatform/python-docs-samples
169- app = 'hello_world'
170185 app_dir = os .path .join (testdata_dir , app )
171186
172187 # Copy sample app to writable temp dir, and generate Dockerfile.
@@ -179,12 +194,15 @@ def test_generate_dockerfile_command(tmpdir, testdata_dir):
179194 compare_against_golden_files (app , config_dir , testdata_dir )
180195
181196
197+ @pytest .mark .parametrize ('app' , [
198+ # Sampled from https://github.com/GoogleCloudPlatform/python-docs-samples
199+ 'hello_world' ,
200+ # From an internal source.
201+ 'hello_world_compat' ])
182202@pytest .mark .xfail (not shutil .which ('gcloud' ),
183203 reason = 'Google Cloud SDK is not installed' )
184- def test_generate_dockerfile_golden (tmpdir , testdata_dir ):
204+ def test_generate_dockerfile_golden (tmpdir , testdata_dir , app ):
185205 """Validate our golden files against gcloud app gen-config"""
186- # Sample from https://github.com/GoogleCloudPlatform/python-docs-samples
187- app = 'hello_world'
188206 app_dir = os .path .join (testdata_dir , app )
189207
190208 # Copy sample app to writable temp dir, and generate Dockerfile.
0 commit comments