Skip to content

Commit

Permalink
Split main() in tests into two parts.
Browse files Browse the repository at this point in the history
So that one part can be replaced on import.
  • Loading branch information
enisoc committed Jan 30, 2015
1 parent f880728 commit 0474326
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions test/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,7 @@ def binary_argstr(name):
# binary management for the MySQL distribution.
def mysql_binary_path(name):
return os.path.join(vt_mysql_root, 'bin', name)

# add environment-specific command-line options
def add_options(parser):
pass
8 changes: 7 additions & 1 deletion test/queryservice_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from topo_flavor.server import set_topo_server_flavor


if __name__ == "__main__":
def main():
parser = optparse.OptionParser(usage="usage: %prog [options] [test_names]")
parser.add_option("-m", "--memcache", action="store_true", default=False,
help="starts a memcache d, and tests rowcache")
Expand All @@ -33,6 +33,9 @@
logging.getLogger().setLevel(logging.ERROR)
utils.set_options(options)

run_tests(options, args)

def run_tests(options, args):
suite = unittest.TestSuite()
if args:
if args[0] == 'teardown':
Expand Down Expand Up @@ -72,3 +75,6 @@
if options.keep_logs:
print("Leaving temporary files behind (--keep-logs), please "
"clean up before next run: " + os.environ["VTDATAROOT"])

if __name__ == "__main__":
main()
4 changes: 4 additions & 0 deletions test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def flush(self):
pass

def add_options(parser):
environment.add_options(parser)
parser.add_option('-d', '--debug', action='store_true',
help='utils.pause() statements will wait for user input')
parser.add_option('-k', '--keep-logs', action='store_true',
Expand Down Expand Up @@ -99,6 +100,9 @@ def main(mod=None):

set_options(options)

run_tests(mod, args)

def run_tests(mod, args):
try:
suite = unittest.TestSuite()
if not args:
Expand Down

0 comments on commit 0474326

Please sign in to comment.