From f7819821c71a687a28319d60bb73083b1abd0138 Mon Sep 17 00:00:00 2001 From: hut Date: Thu, 31 Dec 2009 19:13:08 +0100 Subject: fixed tc_displayable --- ranger/gui/displayable.py | 10 +++++----- test/tc_displayable.py | 20 +++++++++++--------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/ranger/gui/displayable.py b/ranger/gui/displayable.py index c5e1dbac..1929c4e2 100644 --- a/ranger/gui/displayable.py +++ b/ranger/gui/displayable.py @@ -179,19 +179,19 @@ class Displayable(EnvironmentAware, FileManagerAware, SettingsAware): wid = maxx - x if x < 0 or y < 0: - raise OutOfBoundsException("Starting point below zero!") + raise ValueError("Starting point below zero!") #if wid < 1 or hei < 1: # raise OutOfBoundsException("WID and HEI must be >=1!") if x + wid > maxx and y + hei > maxy: - raise OutOfBoundsException("X and Y out of bounds!") + raise ValueError("X and Y out of bounds!") if x + wid > maxx: - raise OutOfBoundsException("X out of bounds!") + raise ValueError("X out of bounds!") if y + hei > maxy: - raise OutOfBoundsException("Y out of bounds!") + raise ValueError("Y out of bounds!") window_is_cleared = False @@ -210,7 +210,7 @@ class Displayable(EnvironmentAware, FileManagerAware, SettingsAware): self.win.resize(hei, wid) except: pass - #raise OutOfBoundsException("Resizing Failed!") + #raise ValueError("Resizing Failed!") self.hei, self.wid = self.win.getmaxyx() diff --git a/test/tc_displayable.py b/test/tc_displayable.py index d7466809..493b0ef8 100644 --- a/test/tc_displayable.py +++ b/test/tc_displayable.py @@ -4,8 +4,7 @@ import unittest import curses from random import randint -from ranger.gui.displayable import\ - Displayable, DisplayableContainer, OutOfBoundsException +from ranger.gui.displayable import Displayable, DisplayableContainer from test import Fake, OK, raise_ok class TestDisplayable(unittest.TestCase): @@ -38,10 +37,10 @@ class TestDisplayable(unittest.TestCase): disp = self.disp hei, wid = self.env.termsize - self.assertRaises(OutOfBoundsException, disp.resize, 0, 0, hei + 1, wid) - self.assertRaises(OutOfBoundsException, disp.resize, 0, 0, hei, wid + 1) - self.assertRaises(OutOfBoundsException, disp.resize, -1, 0, hei, wid) - self.assertRaises(OutOfBoundsException, disp.resize, 0, -1, hei, wid) + self.assertRaises(ValueError, disp.resize, 0, 0, hei + 1, wid) + self.assertRaises(ValueError, disp.resize, 0, 0, hei, wid + 1) + self.assertRaises(ValueError, disp.resize, -1, 0, hei, wid) + self.assertRaises(ValueError, disp.resize, 0, -1, hei, wid) box = (randint(10, 20), randint(30, 40), \ randint(30, 40), randint(10, 20)) @@ -103,11 +102,14 @@ class TestDisplayableContainer(unittest.TestCase): def test_focused_object(self): d1 = Displayable(**self.initdict) d2 = DisplayableContainer(**self.initdict) - d2.add_child(*[Displayable(**self.initdict) for x in range(5)]) + for obj in (Displayable(**self.initdict) for x in range(5)): + d2.add_child(obj) d3 = DisplayableContainer(**self.initdict) - d3.add_child(*[Displayable(**self.initdict) for x in range(5)]) + for obj in (Displayable(**self.initdict) for x in range(5)): + d3.add_child(obj) - self.disc.add_child(d1, d2, d3) + for obj in (d1, d2, d3): + self.disc.add_child(obj) d3.container[3].focused = True -- cgit 1.4.1-2-gfad0