fixes options parameter idempotency issue on v14.x (#60019)

This commit is contained in:
Wojciech Wypior 2019-08-02 22:06:07 -07:00 committed by Tim Rupp
parent d224a7ccf6
commit 95ef456bb7

View file

@ -769,14 +769,19 @@ class Difference(object):
def options(self):
if self.want.options is None:
return None
# starting with v14 options may return as a space delimited string in curly
# braces, eg "{ option1 option2 }", or simply "none" to indicate empty set
if self.have.options is None or self.have.options == 'none':
self.have.options = []
if not isinstance(self.have.options, list):
if self.have.options.startswith('{'):
self.have.options = self.have.options[2:-2].split(' ')
else:
self.have.options = [self.have.options]
if not self.want.options:
if self.have.options is None:
return None
# we don't want options. If we have any, indicate we should remove, else noop
return [] if self.have.options else None
if not self.have.options:
return None
if self.have.options is not None:
return self.want.options
if self.have.options is None:
return self.want.options
if set(self.want.options) != set(self.have.options):
return self.want.options