Ignore:
Timestamp:
12/29/08 12:24:05 (5 years ago)
Author:
xi
Message:

Added basic support for Python 3 (Thanks idadesub(at)users(dot)sourceforge(dot)net).

Location:
pyyaml/trunk/tests3
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • pyyaml/trunk/tests3/test_appliance.py

    r325 r328  
    22import sys, os, os.path, types, traceback, pprint 
    33 
    4 DATA = 'tests/data' 
     4DATA = 'tests3/data' 
    55 
    66def find_test_functions(collections): 
     
    1111        if not isinstance(collection, dict): 
    1212            collection = vars(collection) 
    13         keys = collection.keys() 
    14         keys.sort() 
    15         for key in keys: 
     13        for key in sorted(collection): 
    1614            value = collection[key] 
    1715            if isinstance(value, types.FunctionType) and hasattr(value, 'unittest'): 
     
    2523            base, ext = os.path.splitext(filename) 
    2624            filenames.setdefault(base, []).append(ext) 
    27     filenames = filenames.items() 
    28     filenames.sort() 
     25    filenames = sorted(filenames.items()) 
    2926    return filenames 
    3027 
     
    5249 
    5350def execute(function, filenames, verbose): 
    54     if hasattr(function, 'unittest_name'): 
    55         name = function.unittest_name 
    56     else: 
    57         name = function.func_name 
     51    name = function.__name__ 
    5852    if verbose: 
    5953        sys.stdout.write('='*75+'\n') 
     
    6155    try: 
    6256        function(verbose=verbose, *filenames) 
    63     except Exception, exc: 
     57    except Exception as exc: 
    6458        info = sys.exc_info() 
    6559        if isinstance(exc, AssertionError): 
     
    107101            sys.stdout.write('-'*75+'\n') 
    108102            sys.stdout.write('%s:\n' % filename) 
    109             data = open(filename, 'rb').read() 
     103            data = open(filename, 'r', errors='replace').read() 
    110104            sys.stdout.write(data) 
    111105            if data and data[-1] != '\n': 
     
    124118    results = [] 
    125119    for function in test_functions: 
    126         if include_functions and function.func_name not in include_functions: 
     120        if include_functions and function.__name__ not in include_functions: 
    127121            continue 
    128122        if function.unittest: 
Note: See TracChangeset for help on using the changeset viewer.