PageRenderTime 19ms CodeModel.GetById 12ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/boto-2.5.2/tests/test.py

#
Python | 56 lines | 25 code | 6 blank | 25 comment | 6 complexity | 6c6106ab8187d83064273fc97e221a07 MD5 | raw file
 1#!/usr/bin/env python
 2# Copyright (c) 2006-2011 Mitch Garnaat http://garnaat.org/
 3#
 4# Permission is hereby granted, free of charge, to any person obtaining a
 5# copy of this software and associated documentation files (the
 6# "Software"), to deal in the Software without restriction, including
 7# without limitation the rights to use, copy, modify, merge, publish, dis-
 8# tribute, sublicense, and/or sell copies of the Software, and to permit
 9# persons to whom the Software is furnished to do so, subject to the fol-
10# lowing conditions:
11#
12# The above copyright notice and this permission notice shall be included
13# in all copies or substantial portions of the Software.
14#
15# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
17# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
18# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21# IN THE SOFTWARE.
22
23import logging
24import sys
25import unittest
26
27from nose.core import run
28import argparse
29
30
31def main():
32    parser = argparse.ArgumentParser()
33    parser.add_argument('-t', '--service-tests', action="append", default=[],
34                        help="Run tests for a given service.  This will "
35                        "run any test tagged with the specified value, "
36                        "e.g -t s3 -t ec2")
37    known_args, remaining_args = parser.parse_known_args()
38    attribute_args = []
39    for service_attribute in known_args.service_tests:
40        attribute_args.extend(['-a', '!notdefault,' +service_attribute])
41    if not attribute_args:
42        # If the user did not specify any filtering criteria, we at least
43        # will filter out any test tagged 'notdefault'.
44        attribute_args = ['-a', '!notdefault']
45    all_args = [__file__] + attribute_args + remaining_args
46    print "nose command:", ' '.join(all_args)
47    if run(argv=all_args):
48        # run will return True is all the tests pass.  We want
49        # this to equal a 0 rc
50        return 0
51    else:
52        return 1
53
54
55if __name__ == "__main__":
56    sys.exit(main())