Back to index

python3.2  3.2.2
Classes | Functions | Variables
test.test_decimal Namespace Reference

Classes

class  DecimalTest
class  DecimalExplicitConstructionTest
class  DecimalImplicitConstructionTest
class  DecimalFormatTest
class  DecimalArithmeticOperatorsTest
class  DecimalUseOfContextTest
class  DecimalUsabilityTest
class  DecimalPythonAPItests
class  ContextAPItests
class  WithStatementTest
class  ContextFlags

Functions

def init
def Nonfunction
def thfunc1
def thfunc2
def test_main

Variables

 threading = None
tuple Signals = tuple(getcontext().flags.keys())
tuple OrderedSignals
string TESTDATADIR = 'decimaltestdata'
list file = sys.argv[0]
tuple testdir = os.path.dirname(file)
 directory = testdir+os.sep+TESTDATADIR+os.sep
tuple skip_expected = notos.path.isdir(directory)
tuple skipped_test_ids
 EXTENDEDERRORTEST = False
dictionary ErrorNames
dictionary RoundingDict
dictionary nameAdapter
tuple LOGICAL_FUNCTIONS
tuple p = optparse.OptionParser("test_decimal.py [--debug] [{--skip | test1 [test2 [...]]}]")

Function Documentation

Definition at line 55 of file test_decimal.py.

00055 
00056 def init():
00057     global ORIGINAL_CONTEXT
00058     ORIGINAL_CONTEXT = getcontext().copy()
00059     DefaultTestContext = Context(
00060         prec = 9,
00061         rounding = ROUND_HALF_EVEN,
00062         traps = dict.fromkeys(Signals, 0)
00063         )
00064     setcontext(DefaultTestContext)

Here is the call graph for this function:

Here is the caller graph for this function:

Doesn't do anything.

Definition at line 132 of file test_decimal.py.

00132 
00133 def Nonfunction(*args):
00134     """Doesn't do anything."""
00135     return None

def test.test_decimal.test_main (   arith = False,
  verbose = None,
  todo_tests = None,
  debug = None 
)
Execute the tests.

Runs all arithmetic tests if arith is True or if the "decimal" resource
is enabled in regrtest.py

Definition at line 2360 of file test_decimal.py.

02360 
02361 def test_main(arith=False, verbose=None, todo_tests=None, debug=None):
02362     """ Execute the tests.
02363 
02364     Runs all arithmetic tests if arith is True or if the "decimal" resource
02365     is enabled in regrtest.py
02366     """
02367 
02368     init()
02369     global TEST_ALL, DEBUG
02370     TEST_ALL = arith or is_resource_enabled('decimal')
02371     DEBUG = debug
02372 
02373     if todo_tests is None:
02374         test_classes = [
02375             DecimalExplicitConstructionTest,
02376             DecimalImplicitConstructionTest,
02377             DecimalArithmeticOperatorsTest,
02378             DecimalFormatTest,
02379             DecimalUseOfContextTest,
02380             DecimalUsabilityTest,
02381             DecimalPythonAPItests,
02382             ContextAPItests,
02383             DecimalTest,
02384             WithStatementTest,
02385             ContextFlags
02386         ]
02387     else:
02388         test_classes = [DecimalTest]
02389 
02390     # Dynamically build custom test definition for each file in the test
02391     # directory and add the definitions to the DecimalTest class.  This
02392     # procedure insures that new files do not get skipped.
02393     for filename in os.listdir(directory):
02394         if '.decTest' not in filename or filename.startswith("."):
02395             continue
02396         head, tail = filename.split('.')
02397         if todo_tests is not None and head not in todo_tests:
02398             continue
02399         tester = lambda self, f=filename: self.eval_file(directory + f)
02400         setattr(DecimalTest, 'test_' + head, tester)
02401         del filename, head, tail, tester
02402 
02403 
02404     try:
02405         run_unittest(*test_classes)
02406         if todo_tests is None:
02407             import decimal as DecimalModule
02408             run_doctest(DecimalModule, verbose)
02409     finally:
02410         setcontext(ORIGINAL_CONTEXT)

Here is the call graph for this function:

Definition at line 1189 of file test_decimal.py.

01189 
01190 def thfunc1(cls):
01191     d1 = Decimal(1)
01192     d3 = Decimal(3)
01193     test1 = d1/d3
01194     cls.synchro.wait()
01195     test2 = d1/d3
01196     cls.finish1.set()
01197 
01198     cls.assertEqual(test1, Decimal('0.3333333333333333333333333333'))
01199     cls.assertEqual(test2, Decimal('0.3333333333333333333333333333'))
01200     return

Definition at line 1201 of file test_decimal.py.

01201 
01202 def thfunc2(cls):
01203     d1 = Decimal(1)
01204     d3 = Decimal(3)
01205     test1 = d1/d3
01206     thiscontext = getcontext()
01207     thiscontext.prec = 18
01208     test2 = d1/d3
01209     cls.synchro.set()
01210     cls.finish2.set()
01211 
01212     cls.assertEqual(test1, Decimal('0.3333333333333333333333333333'))
01213     cls.assertEqual(test2, Decimal('0.333333333333333333'))
01214     return
01215 

Here is the call graph for this function:


Variable Documentation

Definition at line 71 of file test_decimal.py.

Initial value:
00001 {'clamped' : Clamped,
00002               'conversion_syntax' : InvalidOperation,
00003               'division_by_zero' : DivisionByZero,
00004               'division_impossible' : InvalidOperation,
00005               'division_undefined' : InvalidOperation,
00006               'inexact' : Inexact,
00007               'invalid_context' : InvalidOperation,
00008               'invalid_operation' : InvalidOperation,
00009               'overflow' : Overflow,
00010               'rounded' : Rounded,
00011               'subnormal' : Subnormal,
00012               'underflow' : Underflow}

Definition at line 118 of file test_decimal.py.

Definition at line 115 of file test_decimal.py.

Definition at line 67 of file test_decimal.py.

Initial value:
00001 (
00002     'is_canonical',
00003     'is_finite',
00004     'is_infinite',
00005     'is_nan',
00006     'is_normal',
00007     'is_qnan',
00008     'is_signed',
00009     'is_snan',
00010     'is_subnormal',
00011     'is_zero',
00012     'same_quantum',
00013     )

Definition at line 188 of file test_decimal.py.

Definition at line 147 of file test_decimal.py.

Initial value:
00001 (Clamped, Rounded, Inexact, Subnormal,
00002                   Underflow, Overflow, DivisionByZero, InvalidOperation)

Definition at line 50 of file test_decimal.py.

tuple test.test_decimal.p = optparse.OptionParser("test_decimal.py [--debug] [{--skip | test1 [test2 [...]]}]")

Definition at line 2413 of file test_decimal.py.

Initial value:
00001 {'ceiling' : ROUND_CEILING, #Maps test-case names to roundings.
00002                 'down' : ROUND_DOWN,
00003                 'floor' : ROUND_FLOOR,
00004                 'half_down' : ROUND_HALF_DOWN,
00005                 'half_even' : ROUND_HALF_EVEN,
00006                 'half_up' : ROUND_HALF_UP,
00007                 'up' : ROUND_UP,
00008                 '05up' : ROUND_05UP}

Definition at line 136 of file test_decimal.py.

tuple test.test_decimal.Signals = tuple(getcontext().flags.keys())

Definition at line 45 of file test_decimal.py.

Definition at line 73 of file test_decimal.py.

Definition at line 77 of file test_decimal.py.

Definition at line 65 of file test_decimal.py.

tuple test.test_decimal.testdir = os.path.dirname(file)

Definition at line 70 of file test_decimal.py.

Definition at line 42 of file test_decimal.py.