Back to index

python3.2  3.2.2
Classes | Functions
test.test_binop Namespace Reference

Classes

class  Rat
class  RatTestCase
class  OperationLogger
class  A
class  B
class  C
class  OperationOrderTests

Functions

def gcd
def isint
def isnum
def isRat
def op_sequence
def test_main

Detailed Description

Tests for binary operators on subtypes of built-in types.

Function Documentation

def test.test_binop.gcd (   a,
  b 
)
Greatest common divisor using Euclid's algorithm.

Definition at line 7 of file test_binop.py.

00007 
00008 def gcd(a, b):
00009     """Greatest common divisor using Euclid's algorithm."""
00010     while a:
00011         a, b = b%a, a
00012     return b

Here is the caller graph for this function:

def test.test_binop.isint (   x)
Test whether an object is an instance of int.

Definition at line 13 of file test_binop.py.

00013 
00014 def isint(x):
00015     """Test whether an object is an instance of int."""
00016     return isinstance(x, int)

Here is the caller graph for this function:

def test.test_binop.isnum (   x)
Test whether an object is an instance of a built-in numeric type.

Definition at line 17 of file test_binop.py.

00017 
00018 def isnum(x):
00019     """Test whether an object is an instance of a built-in numeric type."""
00020     for T in int, float, complex:
00021         if isinstance(x, T):
00022             return 1
00023     return 0

Here is the caller graph for this function:

def test.test_binop.isRat (   x)
Test wheter an object is an instance of the Rat class.

Definition at line 24 of file test_binop.py.

00024 
00025 def isRat(x):
00026     """Test wheter an object is an instance of the Rat class."""
00027     return isinstance(x, Rat)

Here is the caller graph for this function:

def test.test_binop.op_sequence (   op,
  classes 
)
Return the sequence of operations that results from applying
the operation `op` to instances of the given classes.

Definition at line 314 of file test_binop.py.

00314 
00315 def op_sequence(op, *classes):
00316     """Return the sequence of operations that results from applying
00317     the operation `op` to instances of the given classes."""
00318     log = []
00319     instances = []
00320     for c in classes:
00321         instances.append(c(log.append))
00322 
00323     try:
00324         op(*instances)
00325     except TypeError:
00326         pass
00327     return log

Here is the caller graph for this function:

Definition at line 376 of file test_binop.py.

00376 
00377 def test_main():
00378     support.run_unittest(RatTestCase, OperationOrderTests)