Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 71 lines (66 sloc) 2.292 kb
da60d77 @skarab Graduate into a real Python project
skarab authored
1 #!/usr/bin/env python
5e4998f @skarab Refactor exception assertions in tests and add default logging
skarab authored
2 import logging
c7b4892 @skarab Use (optional) test data from files
skarab authored
3 import optparse
f5a3c59 @skarab Add verbosity flag to run_tests
skarab authored
4 import sys
da60d77 @skarab Graduate into a real Python project
skarab authored
5 import unittest
f5a3c59 @skarab Add verbosity flag to run_tests
skarab authored
6
8a5e8c9 @skarab Separate unit tests from online integration/acceptance tests
skarab authored
7 try:
8 import mock
9 except ImportError:
10 sys.stderr.write(
11 "*** Cannot find mock; please make sure it is in the Python path "
12 "or install it (pip install mock)\n")
13 sys.exit(-1)
14
c7b4892 @skarab Use (optional) test data from files
skarab authored
15 from smarkets import __version__
8a5e8c9 @skarab Separate unit tests from online integration/acceptance tests
skarab authored
16 from tests import unit_tests, integration_tests
da60d77 @skarab Graduate into a real Python project
skarab authored
17
18
19 if __name__ == '__main__':
c7b4892 @skarab Use (optional) test data from files
skarab authored
20 version = "%%prog %s" % __version__
21 parser = optparse.OptionParser(version=version)
22 parser.add_option(
23 '-v', '--verbose', dest='verbose', action='store_true',
24 default=False, help="turn on DEBUG logging level")
25 parser.add_option(
26 '-f', '--file', dest='password_filename',
8a5e8c9 @skarab Separate unit tests from online integration/acceptance tests
skarab authored
27 help="read usernames and passwords from FILE (integration only)",
c7b4892 @skarab Use (optional) test data from files
skarab authored
28 metavar='FILE')
29 parser.add_option(
30 '-m', '--markets', dest='market_filename',
8a5e8c9 @skarab Separate unit tests from online integration/acceptance tests
skarab authored
31 help="read markets from FILE (integration only)",
c7b4892 @skarab Use (optional) test data from files
skarab authored
32 metavar='FILE')
33 parser.add_option(
34 '-s', '--server', dest='server',
8a5e8c9 @skarab Separate unit tests from online integration/acceptance tests
skarab authored
35 help="server host to connect to (integration only)",
c7b4892 @skarab Use (optional) test data from files
skarab authored
36 metavar='SERVER')
37 parser.add_option(
38 '-p', '--port', dest='port',
8a5e8c9 @skarab Separate unit tests from online integration/acceptance tests
skarab authored
39 help="server port to connect to (integration only)",
c7b4892 @skarab Use (optional) test data from files
skarab authored
40 metavar='PORT')
41 parser.add_option(
8a5e8c9 @skarab Separate unit tests from online integration/acceptance tests
skarab authored
42 '-i', '--run-integration', dest='run_integration', action='store_true',
43 default=False,
44 help="run integration tests (only possible if you have a 'test' "
45 "API service available)")
459a9df Add SSL option for integration tests
Paul Oliver authored
46 parser.add_option(
86e1d6d Default SSL to true
Paul Oliver authored
47 '-t', '--disable-ssl', dest='ssl', action='store_false',
48 default=True,
49 help="disable ssl (only possible if configured on 'test' API service)")
c7b4892 @skarab Use (optional) test data from files
skarab authored
50 options, args = parser.parse_args()
5e4998f @skarab Refactor exception assertions in tests and add default logging
skarab authored
51 level = logging.WARNING
c7b4892 @skarab Use (optional) test data from files
skarab authored
52 if options.verbose:
5e4998f @skarab Refactor exception assertions in tests and add default logging
skarab authored
53 level = logging.DEBUG
54 logging.basicConfig(level=level)
8a5e8c9 @skarab Separate unit tests from online integration/acceptance tests
skarab authored
55 suite = unittest.TestSuite()
56 unit_tests(suite)
c7b4892 @skarab Use (optional) test data from files
skarab authored
57 kwargs = {}
8a5e8c9 @skarab Separate unit tests from online integration/acceptance tests
skarab authored
58 if options.run_integration:
59 for name in (
60 'password_filename',
61 'market_filename',
62 'server',
63 'port',
459a9df Add SSL option for integration tests
Paul Oliver authored
64 'ssl',
8a5e8c9 @skarab Separate unit tests from online integration/acceptance tests
skarab authored
65 ):
66 val = getattr(options, name)
67 if val:
68 kwargs[name] = val
69 integration_tests(suite, **kwargs)
70 results = unittest.TextTestRunner().run(suite)
Something went wrong with that request. Please try again.