> > def is_empty(self):
> >- """
> >- Is screen history empty.
> >- @return boolean value. True if history is empty, otherwise False.
> >- """
> >+ '''Is screen history empty'''
> > if len(self.screens) == 0:
> > return True
> > else:
> > return False
> >
>
> Maybe a @property makes sense here instead of a method call to fit with the
> recent changes we've made.
> The docstring needs a full stop.
is_empty is now a property (and I threw in a new test case to boot). Here is the partial diff:
+ @property
def is_empty(self):
- '''Is screen history empty'''
+ '''Return a boolean indicating if the screen history is empty.'''
if len(self.screens) == 0:
return True
else:
def _handle_navigate_back(self, event):
'''Handle UserEvent.NAVIGATE_BACK.'''
- if not self.history.is_empty():
+ if not self.history.is_empty: self.move_to_previous_screen()
Samuel,
> > def is_empty(self):
> >- """
> >- Is screen history empty.
> >- @return boolean value. True if history is empty, otherwise False.
> >- """
> >+ '''Is screen history empty'''
> > if len(self.screens) == 0:
> > return True
> > else:
> > return False
> >
>
> Maybe a @property makes sense here instead of a method call to fit with the
> recent changes we've made.
> The docstring needs a full stop.
is_empty is now a property (and I threw in a new test case to boot). Here is the partial diff:
matt@eden: ~/repo/ translate- events/ entertainerlib/ tests$ bzr diff -r -3..-1 /frontend/ gui/screen_ history. py' frontend/ gui/screen_ history. py 2009-06-02 01:16:03 +0000 frontend/ gui/screen_ history. py 2009-06-03 01:54:03 +0000
=== modified file 'entertainerlib
--- entertainerlib/
+++ entertainerlib/
@@ -26,8 +26,9 @@
return None
return self.screens.pop()
+ @property
def is_empty(self):
- '''Is screen history empty'''
+ '''Return a boolean indicating if the screen history is empty.'''
if len(self.screens) == 0:
return True
else:
=== modified file 'entertainerlib /frontend/ gui/user_ interface. py' frontend/ gui/user_ interface. py 2009-06-02 01:16:03 +0000 frontend/ gui/user_ interface. py 2009-06-03 01:54:03 +0000
--- entertainerlib/
+++ entertainerlib/
@@ -351,7 +351,7 @@
def _handle_ navigate_ back(self, event): NAVIGATE_ BACK.'' ' is_empty( ): is_empty:
self. move_to_ previous_ screen( )
'''Handle UserEvent.
- if not self.history.
+ if not self.history.
def _handle_ navigate_ home(self, event):
=== added file 'entertainerlib /tests/ test_screenhist ory.py' tests/test_ screenhistory. py 1970-01-01 00:00:00 +0000 tests/test_ screenhistory. py 2009-06-03 01:54:03 +0000 frontend. gui.screen_ history import ScreenHistory frontend. gui.screens. screen import Screen tests import EntertainerTest st(EntertainerT est): frontend. gui.screen_ history' '' .setUp( self) (isinstance( self.screen_ history, ScreenHistory)) empty(self) : (self.screen_ history. is_empty) history. add_screen( screen) e(self. screen_ history. is_empty)
--- entertainerlib/
+++ entertainerlib/
@@ -0,0 +1,26 @@
+# Copyright (c) 2009 Entertainer Developers - See COPYING - GPLv2
+'''Tests ScreenHistory'''
+
+from entertainerlib.
+from entertainerlib.
+from entertainerlib.
+
+class ScreenHistoryTe
+ '''Test for entertainerlib.
+
+ def setUp(self):
+ EntertainerTest
+
+ self.screen_history = ScreenHistory(None)
+
+ def test_create(self):
+ '''Test correct ScreenHistory initialization.'''
+ self.assertTrue
+
+ def test_is_
+ '''Test the is_empty property.'''
+ self.assertTrue
+ screen = Screen()
+ self.screen_
+ self.assertFals
+