homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author zach.ware
Recipients ezio.melotti, facundobatista, mark.dickinson, rhettinger, skrah, zach.ware
Date 2013年12月17日.21:24:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1387315472.11.0.523562380055.issue20008@psf.upfronthosting.co.za>
In-reply-to
Content
This patch makes extensive changes to test_decimal, with the ultimate goal of making `python -m unittest discover Lib/test/ "test_*.py"` not choke on test_decimal (see issue16748). Trying to do so uncovered a few other issues, such as some tests not properly cleaning up the context.
Here's a (non-exhaustive) list of what the patch will do:
- Clean up imports, including a repeated import of warnings
- Create a new hierarchy of TestCase subclasses
 - BaseTestCase is an empty subclass of unittest.TestCase to serve
 as a base class for all tests that are meant to test both
 implementations. This makes it easy to find such tests and
 create the implementation-specific test cases programmatically.
 - DecimalTest defines some methods for all tests:
 - setUp and tearDown, which ensure that the context is set up
 properly and cleaned up properly. A test that changes the
 context is marked as a failure in tearDown. These take the
 place of the toplevel init(module) function.
 - assertSignals, formerly toplevel assert_signals. It has
 also been enhanced to provide the current context if no
 context is given, and to accept strings as signals (which
 are then looked up on the current decimal module to get the
 real exception)
 - assertAndClearFlags, which is a shortcut for
 assertSignals('flags' ...) and clears the flags when done.
 Several tests made no changes to the context except for
 flags, and this was a quick, easy, and convenient way to
 confirm behavior and clean up.
 - CDecimalTest and PyDecimalTest, subclasses of DecimalTest which
 can be inherited from directly by tests that are meant for a
 single implementation (such as C/PyWhitebox, C/PyFunctionality),
 and are inherited by the generated subclasses of the base classes
 (IBMTestCases, FormatTest, etc.)
- Do away with the 'skip_expected' global, use a decorator to skip
 IBMTestCases if the test data can't be found.
- Clean up other toplevel setup code a bit.
- Make vertical spacing more consistent throughout the module.
- Move a couple of tests into `with localcontext()` blocks to avoid
 context pollution.
- Decorate all of CFunctionality with @requires_extra_functionality
 instead of each individual test
- Remove the explicit listing of test classes.
- Remove test_main().
- Add a Doctests base class which runs the doctests via 
 doctest.testmod() and expects a certain number of tests to have been
 run. Attempts to use doctest.DocTestSuite were stymied by the
 two-headed nature of decimal and _decimal, and would have required a 
 load_tests function to load them anyway.
- Add tearDownModule, which restores the original contexts and checks
 to make sure sys.modules['decimal'] is as expected.
- Convert `if __name__ == '__main__'` argument handling from optparse 
 to argparse.
 - Allow arguments to be passed through to unittest.main().
 - The old method of specifying IBM test case names now requires a
 '--test' or '-t' switch before each set of names (more than one
 -t switch can be present, but each must have at least one name
 following).
 - Add an '--extended'/'-e' switch for switching
 'EXTENDEDERRORTEST', which formerly required editing the file.
- Use unittest.main() for running the script directly.
With the patch test_decimal can be run successfully: directly, by regrtest, or by unittest discovery in Lib/test/; with any acceptable combination of arguments when run directly; with or without _decimal; with or without -OO. I have not yet been able to test -DEXTRA_FUNCTIONALITY, --without-docstrings, or on any platform but Windows, but I don't expect any issues (of course :).
The patch is against default; 3.3 requires the removal of a usage of subTest and a tweaking of the Doctest expected results.
Any review will be very much appreciated!
Thanks,
Zach
History
Date User Action Args
2013年12月17日 21:24:33zach.waresetrecipients: + zach.ware, rhettinger, facundobatista, mark.dickinson, ezio.melotti, skrah
2013年12月17日 21:24:32zach.waresetmessageid: <1387315472.11.0.523562380055.issue20008@psf.upfronthosting.co.za>
2013年12月17日 21:24:31zach.warelinkissue20008 messages
2013年12月17日 21:24:29zach.warecreate

AltStyle によって変換されたページ (->オリジナル) /