Trees | Indices | Help |
---|
|
1 # -*- Mode: Python; test-case-name: test_command -*- 2 # vi:si:et:sw=4:sts=4:ts=4 3 # 4 # Copyright (C) 2006,2007 Thomas Vander Stichele <thomas at apestaart dot org> 5 6 # This program is free software; you can redistribute it and/or modify 7 # it under the terms of the GNU General Public License as published by 8 # the Free Software Foundation; either version 2 of the License, or 9 # (at your option) any later version. 10 # 11 # This program is distributed in the hope that it will be useful, 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 # GNU General Public License for more details. 15 # 16 # You should have received a copy of the GNU General Public License 17 # along with this program; if not, write to the Free Software 18 # Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. 19 20 import sys 21 import unittest 22 import StringIO 23 24 import command 25 26 40 41 45 46 50 51 55 565881 8260 unittest.TestCase.setUp(self) 61 self.out = StringIO.StringIO() 62 self.err = StringIO.StringIO() 63 self.c = FakeCommand(stdout=self.out, stderr=self.err) 64 self.assertEquals(self.c.name, "fakecommand")6567 self.assertEquals(None, self.c.parse(['--help', ])) 68 lookFor = "%s " % self.c.subCommands.keys()[0] 69 self.failUnless(self.out.getvalue().find(lookFor) > -1, 70 "out %r does not contain %s" % (self.out.getvalue(), lookFor))7173 ret = self.c.parse([]) 74 self.assertEquals(ret, 1) 75 out = self.err.getvalue() 76 self.failIf(out, "Should not get output on stderr, but got %r" % out) 77 # It seems the F7 version uppercases the first letter, making it Usage 78 out = self.out.getvalue() 79 self.failUnless(out[1:].startswith('sage:'), 80 "output %s does not start with U/usage" % out)8497 98 99 if __name__ == '__main__': 100 unittest.main() 10186 unittest.TestCase.setUp(self) 87 self.out = StringIO.StringIO() 88 self.err = StringIO.StringIO() 89 self.c = FakeSubCommand(stdout=self.out, stderr=self.err) 90 self.assertEquals(self.c.name, "fakesubcommand")9193 self.assertEquals(None, self.c.parse(['--help', ])) 94 lookFor = "%s " % self.c.subCommands.keys()[0] 95 self.failUnless(self.out.getvalue().find(lookFor) > -1, 96 "out %r does not contain %s" % (self.out.getvalue(), lookFor))
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Mon May 11 07:29:01 2015 | http://epydoc.sourceforge.net |