[master][PATCH 0/2] Make sure bool is returned if expected

Martin Kolman mkolman at redhat.com
Wed Oct 23 15:33:38 UTC 2013


The ready, completed and mandatory spoke properties should and mostly do return
booleans. But recently, during testing of the baserepo cache patchset, the patches
made one property return None instead of False. One would not expect it to be a big
deal, but we are using those properties with GI and GI expects either True or False.
None being returned by the property causes GI to throw an exception.

Therefore, I've added a decorator, called returns_bool, that converts the return
value of the decorated function to a boolean. This should make GI happy, generally
reinforce the idea that the ready, completed and mandatory properties return bools
and also gets rid of some code converting the result to bool.

The first patch adds the returns_bool decorator to iutil and decorates
all relevant properties with it.

The second patch adds tests for the returns_bool decorator.
The tests both check if a bool class instance is returned and that
various values are correctly converted to True/False.

Martin Kolman (2):
  Make sure to return bool if bool is expected in spokes
  Add tests for the returns bool decorator

 pyanaconda/iutil.py                        | 26 ++++++++++++++++++
 pyanaconda/ui/common.py                    |  4 +++
 pyanaconda/ui/gui/spokes/__init__.py       |  2 ++
 pyanaconda/ui/gui/spokes/custom.py         |  1 +
 pyanaconda/ui/gui/spokes/datetime_spoke.py |  3 +++
 pyanaconda/ui/gui/spokes/keyboard.py       |  2 ++
 pyanaconda/ui/gui/spokes/langsupport.py    |  3 +++
 pyanaconda/ui/gui/spokes/network.py        |  3 +++
 pyanaconda/ui/gui/spokes/password.py       |  5 +++-
 pyanaconda/ui/gui/spokes/software.py       |  4 +++
 pyanaconda/ui/gui/spokes/source.py         |  4 +++
 pyanaconda/ui/gui/spokes/storage.py        |  3 +++
 pyanaconda/ui/gui/spokes/user.py           |  3 +++
 pyanaconda/ui/gui/spokes/welcome.py        |  2 ++
 pyanaconda/ui/tui/__init__.py              |  1 +
 pyanaconda/ui/tui/simpleline/widgets.py    |  2 ++
 pyanaconda/ui/tui/spokes/__init__.py       |  2 ++
 pyanaconda/ui/tui/spokes/askvnc.py         |  2 ++
 pyanaconda/ui/tui/spokes/network.py        |  2 ++
 pyanaconda/ui/tui/spokes/password.py       |  3 +++
 pyanaconda/ui/tui/spokes/progress.py       |  2 ++
 pyanaconda/ui/tui/spokes/shell_spoke.py    |  2 ++
 pyanaconda/ui/tui/spokes/software.py       |  3 +++
 pyanaconda/ui/tui/spokes/source.py         |  3 +++
 pyanaconda/ui/tui/spokes/storage.py        |  4 +++
 pyanaconda/ui/tui/spokes/time_spoke.py     |  5 +++-
 pyanaconda/ui/tui/spokes/user.py           |  3 +++
 pyanaconda/ui/tui/spokes/warnings.py       |  2 ++
 tests/pyanaconda_tests/iutil_test.py       | 42 +++++++++++++++++++++++++++++-
 29 files changed, 140 insertions(+), 3 deletions(-)

-- 
1.8.3.1



More information about the anaconda-patches mailing list