Assert environment is what we expect

pull/82224/head
Matt Martz 5 months ago
parent b048e0e2a6
commit 54421856bc
No known key found for this signature in database
GPG Key ID: 40832D88E9FC91D8

@ -644,7 +644,7 @@ class AnsibleEnvironment(NativeEnvironment):
('trim_blocks', self.trim_blocks),
('variable_end_string', self.variable_end_string),
('variable_start_string', self.variable_start_string),
('native', self.__class__ == AnsibleNativeEnvironment),
('native', self.__class__ is AnsibleNativeEnvironment),
)
)
return f'{source}[overrides={overrides}]'
@ -764,6 +764,9 @@ class Templar:
:returns: Copy of Templar with updated environment.
"""
if environment_class not in {AnsibleEnvironment, AnsibleNativeEnvironment}:
raise AnsibleAssertionError('environment_class must be one of AnsibleEnvironment or AnsibleNativeEnvironment')
# We need to use __new__ to skip __init__, mainly not to create a new
# environment there only to override it below
new_env = object.__new__(environment_class)

Loading…
Cancel
Save