Source

HORNET / tests / run_tests.py

Full commit
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2009 Vanderbilt University
# 
# Licensed under the Apache License, Version 2.0 (the "License"); 
# you may not use this file except in compliance with the License. 
# You may obtain a copy of the License at 
# 
#     http://www.apache.org/licenses/LICENSE-2.0 
# 
# Unless required by applicable law or agreed to in writing, software 
# distributed under the License is distributed on an "AS IS" BASIS, 
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
# See the License for the specific language governing permissions and 
# limitations under the License. 

from os import path
import logging
import nose
import sys

NOSE_ARGS = ['', ## first slot empty (simulates program name
             '--verbosity=3',
             #'--with-doctest',
             ]

def main(argv=None):
    ## set up logging
    formatter = logging.Formatter('%(name)s - %(levelname)s - %(message)s')
    console = logging.StreamHandler()
    console.setLevel(logging.ERROR)
    console.setFormatter(formatter)
    logging.getLogger('hornet').addHandler(console)
    
    ## add the hornet code to the PYTHONPATH
    def insert_path(location):
        sys.path.insert(0, location)
    
    insert_path(path.dirname(path.abspath(__file__)))
    insert_path(path.join(path.dirname(path.abspath(__file__)), path.pardir, 'src'))
    
    if argv != None:
        nose_args = NOSE_ARGS + argv
    else:
        nose_args = NOSE_ARGS
    print 'Running nose with arguments:', ' '.join(nose_args[1:])
    nose.main(argv=nose_args)

if __name__ == '__main__':
    main(sys.argv[1:])