Include the _sortCommand to the _setCommand method (vponcova, #1578930)

This commit is contained in:
David Cantrell 2018-05-22 15:40:43 -04:00
parent 479effc7fb
commit 17c2693c74
2 changed files with 62 additions and 1 deletions

View File

@ -0,0 +1,56 @@
commit f618b966fe3358b89412e58b9b249edb35b154dc
Author: Vendula Poncova <vponcova@redhat.com>
Date: Thu May 17 20:38:22 2018 +0200
Include the _sortCommand to the _setCommand method (#1578930)
The _sortCommand method should be part of the _setCommand method,
otherwise we might set the command without changing the _writeOrder
dictionary.
This should fix the resetCommand method, where the dictionary wasn't
updated, so the old instance of the command was used to generate the
kickstart representation.
Resolves: rhbz#1578930
diff --git a/pykickstart/base.py b/pykickstart/base.py
index 00b5c8f..f695dcc 100644
--- a/pykickstart/base.py
+++ b/pykickstart/base.py
@@ -306,7 +306,6 @@ class KickstartHandler(KickstartObject):
setattr(self, name.lower(), cmdObj)
- def _sortCommand(self, cmdObj):
# Also, add the object into the _writeOrder dict in the right place.
if cmdObj.writePriority is not None:
if cmdObj.writePriority in self._writeOrder:
@@ -332,7 +331,6 @@ class KickstartHandler(KickstartObject):
if cmdObj is None:
cmdObj = cmdClass()
self._setCommand(cmdObj)
- self._sortCommand(cmdObj)
# Finally, add the mapping to the commands dict.
self.commands[cmdName] = cmdObj
diff --git a/tests/base.py b/tests/base.py
index 2d3961c..e1f4689 100644
--- a/tests/base.py
+++ b/tests/base.py
@@ -232,6 +232,7 @@ class HandlerResetCommand_TestCase(ParserTest):
self.assertTrue(self.handler.autopart.encrypted)
self.assertEqual(self.handler.autopart.passphrase, "something")
self.assertTrue(self.handler.autopart.bogus)
+ self.assertTrue("autopart" in str(self.handler))
self.handler.resetCommand("autopart")
self.assertFalse(self.handler.autopart.autopart)
@@ -239,6 +240,7 @@ class HandlerResetCommand_TestCase(ParserTest):
self.assertFalse(self.handler.autopart.encrypted)
self.assertEqual(self.handler.autopart.passphrase, "")
self.assertNotIn("bogus", self.handler.autopart.__dict__)
+ self.assertFalse("autopart" in str(self.handler))
class HandlerDispatch_TestCase(ParserTest):
def runTest(self):

View File

@ -11,7 +11,7 @@
Name: pykickstart
Version: 3.14
Release: 1%{?dist}
Release: 2%{?dist}
License: GPLv2 and MIT
Group: System Environment/Libraries
Summary: Python utilities for manipulating kickstart files.
@ -20,6 +20,7 @@ Url: http://fedoraproject.org/wiki/pykickstart
# our distribution. Thus the source is only available from
# within this srpm.
Source0: %{name}-%{version}.tar.gz
Patch0: pykickstart-rhbz1578930.patch
BuildArch: noarch
@ -77,6 +78,7 @@ the pykickstart package.
%prep
%setup -q
%patch0 -p1
%if %{with python2}
rm -rf %{py3dir}
@ -142,6 +144,9 @@ make PYTHON=%{__python3} test
%{python3_sitelib}/pykickstart*.egg-info
%changelog
* Tue May 22 2018 David Cantrell <dcantrell@redhat.com> - 3.14-2
- Include the _sortCommand to the _setCommand method (vponcova, #1578930)
* Mon May 14 2018 David Cantrell <dcantrell@redhat.com> - 3.14-1
- Increment version to 3.14 (dcantrell)
- Commit the new version in make bumpver. (dcantrell)