@@ -173,17 +173,36 @@ def test_v3_ansible_install_refs(self, exec_env_definition_file):
173173 {'version': 3,
174174 'images': { 'base_image': {'name': 'base_image:latest'}},
175175 'dependencies': {
176- 'ansible_core': {'package_pip': 'ansible-core==2.13 '},
176+ 'ansible_core': {'package_pip': 'ansible-core'},
177177 'ansible_runner': { 'package_pip': 'ansible-runner==2.3.1'}
178178 }
179179 }
180180 """
181181 )
182182 definition = UserDefinition (path )
183183 definition .validate ()
184- assert definition .ansible_core_ref == "ansible-core==2.13 "
184+ assert definition .ansible_core_ref == "ansible-core"
185185 assert definition .ansible_runner_ref == "ansible-runner==2.3.1"
186- assert definition .ansible_ref_install_list == "ansible-core==2.13 ansible-runner==2.3.1"
186+ assert definition .ansible_ref_install_list == "ansible-core ansible-runner==2.3.1"
187+
188+ def test_v3_ansible_install_ref_pin_required (self , monkeypatch , exec_env_definition_file ):
189+ path = exec_env_definition_file (
190+ """
191+ {'version': 3,
192+ 'images': { 'base_image': {'name': 'base_image:latest'}},
193+ 'dependencies': {
194+ 'ansible_core': {'package_pip': 'ansible-core'},
195+ 'ansible_runner': { 'package_pip': 'ansible-runner==2.3.1'}
196+ }
197+ }
198+ """
199+ )
200+ monkeypatch .setattr (constants , 'REQUIRE_ANSIBLE_CORE_PIN' , True )
201+ definition = UserDefinition (path )
202+ definition .validate ()
203+ with pytest .raises (DefinitionError ) as error :
204+ _ = definition .ansible_core_ref
205+ assert "Value for 'ansible_core' must contain a version constraint" in str (error .value .args [0 ])
187206
188207 def test_v3_inline_python (self , exec_env_definition_file ):
189208 """
0 commit comments