[issue2674] unittest.TestProgram uses sys.exit()
New submission from Johan Tufvesson <[EMAIL PROTECTED]>: The class TestProgram (and its synonym "main") in module unittest is (probably) meant to be an easy way to use the functionality of the module unittest. It is very surprising (and error-prone) that it uses sys.exit() with a status code instead of making a return with the same status code. Clean-up actions after the call to unittest.main() are not executed. -- components: Library (Lib) messages: 65698 nosy: tuben severity: normal status: open title: unittest.TestProgram uses sys.exit() type: behavior versions: Python 2.5 __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2674> __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6966] Ability to refer to arguments in TestCase.fail* methods
New submission from Johan Tufvesson : In the unittest module, TestCase class: If one wants to provide a more descriptive fail message compared to the default, it is often valuable to be able to refer to the arguments evaluated by the fail*- (or assert*-) method. This can be accomplished by binding names to the evaluated values before the call to the fail*-methods, and then providing a string with the values embedded as needed. This, however, can be quite cumbersome when there are a lot of calls to fail*-methods. Today: Arg1 = RealValue() Arg2 = ExpectedValue() self.failUnlessEqual(Arg1, Arg2, "Got {0}, but expected {1}.".format(Arg1, Arg2)) Proposed solution: In the fail*-methods, check if the msg argument is some kind of string (basestring?), and run the format() method on the string with the supplied arguments. This would result in code like this: self.failUnlessEqual(RealValue(), ExpectedValue(), "Got {0}, but expected {1}.") -- components: Library (Lib) messages: 92977 nosy: tuben severity: normal status: open title: Ability to refer to arguments in TestCase.fail* methods type: feature request versions: Python 2.7 ___ Python tracker <http://bugs.python.org/issue6966> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6966] Ability to refer to arguments in TestCase.fail* methods
Johan Tufvesson added the comment: I admit that I had not seen the longMessage attribute. That is better than the present possibilities in 2.6, although not as configurable as my suggestion (but with better backwards compatibility). Personally I will be a user of the longMessage feature, dreaming of even more functionality. -- ___ Python tracker <http://bugs.python.org/issue6966> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com