Fix Gentoo "is" comparisons

We should not be using "is" to equate literals.  It must have been
working by accident but breaks in recent Python 3.  Appears to been
like this since initial commit with
Iaa17b6ce2444dd48a3f5fcf8eeb9f46ce6077bf7.

Change-Id: Iae85431e03d2db93376798e10cddb8f43ec67be2
This commit is contained in:
Ian Wienand 2021-04-27 14:08:22 +10:00
parent c2e2a920e8
commit 32a7409814
2 changed files with 3 additions and 3 deletions

View File

@ -1466,7 +1466,7 @@ def set_hostname_from_config_drive(args, meta_data):
raise RuntimeError('Error setting hostname')
else:
# gentoo's hostname file is in a different location
if args.distro is 'gentoo':
if args.distro == 'gentoo':
with open('/etc/conf.d/hostname', 'w') as fh:
fh.write("hostname=\"{host}\"\n".format(host=hostname))
else:

View File

@ -267,9 +267,9 @@ class TestGlean(base.BaseTestCase):
hostname = meta_data['name']
mock_call.assert_has_calls([mock.call(['hostname', hostname])])
if distro.lower() is 'gentoo':
if distro.lower() == 'gentoo':
(self.file_handle_mocks['/etc/conf.d/hostname'].write.
assert_has_calls([mock.call(hostname)]))
assert_has_calls([mock.call('hostname="%s"\n' % hostname)]))
else:
self.file_handle_mocks['/etc/hostname'].write.assert_has_calls(
[mock.call(hostname), mock.call('\n')])