Browse Source

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
changes/26/788126/2
Ian Wienand 3 weeks ago
parent
commit
32a7409814
2 changed files with 3 additions and 3 deletions
  1. +1
    -1
      glean/cmd.py
  2. +2
    -2
      glean/tests/test_glean.py

+ 1
- 1
glean/cmd.py 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:


+ 2
- 2
glean/tests/test_glean.py 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')])


Loading…
Cancel
Save