| 1 |
#!/usr/bin/env python3 |
| 2 |
# -*- mode: python -*- |
| 3 |
# -*- coding: utf-8 -*- |
| 4 |
|
| 5 |
# Licensed to the Apache Software Foundation (ASF) under one |
| 6 |
# or more contributor license agreements. See the NOTICE file |
| 7 |
# distributed with this work for additional information |
| 8 |
# regarding copyright ownership. The ASF licenses this file |
| 9 |
# to you under the Apache License, Version 2.0 (the |
| 10 |
# "License"); you may not use this file except in compliance |
| 11 |
# with the License. You may obtain a copy of the License at |
| 12 |
# |
| 13 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 14 |
# |
| 15 |
# Unless required by applicable law or agreed to in writing, software |
| 16 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 17 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 18 |
# See the License for the specific language governing permissions and |
| 19 |
# limitations under the License. |
| 20 |
|
| 21 |
"""Runs all tests. |
| 22 |
|
| 23 |
Usage: |
| 24 |
|
| 25 |
- Run tests from all modules: |
| 26 |
./run_tests.py discover [-v] |
| 27 |
|
| 28 |
- Run tests in a specific module: |
| 29 |
./run_tests.py test_schema [-v] |
| 30 |
|
| 31 |
- Run a specific test: |
| 32 |
./run_tests.py test_schema.TestSchema.testParse [-v] |
| 33 |
|
| 34 |
- Set logging level: |
| 35 |
PYTHON_LOG_LEVEL=<log-level> ./run_tests.py ... |
| 36 |
log-level 0 includes all logging. |
| 37 |
log-level 10 includes debug logging. |
| 38 |
log-level 20 includes info logging. |
| 39 |
|
| 40 |
- Command-line help: |
| 41 |
./run_tests.py -h |
| 42 |
./run_tests.py discover -h |
| 43 |
""" |
| 44 |
|
| 45 |
import logging |
| 46 |
import os |
| 47 |
import sys |
| 48 |
import unittest |
| 49 |
|
| 50 |
from avro.tests.test_datafile import * |
| 51 |
from avro.tests.test_datafile_interop import * |
| 52 |
from avro.tests.test_io import * |
| 53 |
from avro.tests.test_ipc import * |
| 54 |
from avro.tests.test_protocol import * |
| 55 |
from avro.tests.test_schema import * |
| 56 |
from avro.tests.test_script import * |
| 57 |
from avro.tests.test_enum import * |
| 58 |
|
| 59 |
|
| 60 |
def SetupLogging(): |
| 61 |
log_level = int(os.environ.get('PYTHON_LOG_LEVEL', logging.INFO)) |
| 62 |
|
| 63 |
log_formatter = logging.Formatter( |
| 64 |
'%(asctime)s %(levelname)s %(filename)s:%(lineno)s : %(message)s') |
| 65 |
logging.root.handlers = list() # list.clear() only exists in python 3.3+ |
| 66 |
logging.root.setLevel(log_level) |
| 67 |
console_handler = logging.StreamHandler() |
| 68 |
console_handler.setFormatter(log_formatter) |
| 69 |
console_handler.setLevel(logging.DEBUG) |
| 70 |
logging.root.addHandler(console_handler) |
| 71 |
|
| 72 |
|
| 73 |
SetupLogging() |
| 74 |
|
| 75 |
|
| 76 |
if __name__ == '__main__': |
| 77 |
unittest.main() |