import unittest
import argparse

"""
Use this script either without arguments to run all tests:
    python client_test_run.py
or with specific module/test to run only part of the test suite:
    python client_test_run.py pdc_client.tests.release.tests.ReleaseTestCase.test_list_all
"""

if __name__ == '__main__':
    parser = argparse.ArgumentParser('client_test_run.py')
    parser.add_argument('tests', metavar='TEST', nargs='*')
    options = parser.parse_args()
    loader = unittest.TestLoader()
    if options.tests:
        suite = loader.loadTestsFromNames(options.tests)
    else:
        suite = loader.discover('pdc_client/tests', top_level_dir='.')
    unittest.TextTestRunner().run(suite)

import unittest
import argparse
import sys

"""
Use this script either without arguments to run all tests:
    python client_test_run.py
or with specific module/test to run only part of the test suite:
    python client_test_run.py pdc_client.tests.release.tests.ReleaseTestCase.test_list_all
"""

if __name__ == '__main__':
    parser = argparse.ArgumentParser('client_test_run.py')
    parser.add_argument('tests', metavar='TEST', nargs='*')
    options = parser.parse_args()
    loader = unittest.TestLoader()
    if options.tests:
        suite = loader.loadTestsFromNames(options.tests)
    else:
        suite = loader.discover('pdc_client/tests', top_level_dir='.')
    result = unittest.TextTestRunner().run(suite)
    if not result.wasSuccessful():
        sys.exit(1)

Exit with 1 if client tests fail
Exit with 1 if client tests fail

  import unittest
  import argparse
+ import sys
  
  """
  Use this script either without arguments to run all tests:
      python client_test_run.py
  or with specific module/test to run only part of the test suite:
      python client_test_run.py pdc_client.tests.release.tests.ReleaseTestCase.test_list_all
  """
  
  if __name__ == '__main__':
      parser = argparse.ArgumentParser('client_test_run.py')
      parser.add_argument('tests', metavar='TEST', nargs='*')
      options = parser.parse_args()
      loader = unittest.TestLoader()
      if options.tests:
          suite = loader.loadTestsFromNames(options.tests)
      else:
          suite = loader.discover('pdc_client/tests', top_level_dir='.')
-     unittest.TextTestRunner().run(suite)
+     result = unittest.TextTestRunner().run(suite)
+     if not result.wasSuccessful():
+         sys.exit(1)
  
Exit with 1 if client tests fail
## Code Before:
import unittest
import argparse

"""
Use this script either without arguments to run all tests:
    python client_test_run.py
or with specific module/test to run only part of the test suite:
    python client_test_run.py pdc_client.tests.release.tests.ReleaseTestCase.test_list_all
"""

if __name__ == '__main__':
    parser = argparse.ArgumentParser('client_test_run.py')
    parser.add_argument('tests', metavar='TEST', nargs='*')
    options = parser.parse_args()
    loader = unittest.TestLoader()
    if options.tests:
        suite = loader.loadTestsFromNames(options.tests)
    else:
        suite = loader.discover('pdc_client/tests', top_level_dir='.')
    unittest.TextTestRunner().run(suite)

## Instruction:
Exit with 1 if client tests fail
## Code After:
import unittest
import argparse
import sys

"""
Use this script either without arguments to run all tests:
    python client_test_run.py
or with specific module/test to run only part of the test suite:
    python client_test_run.py pdc_client.tests.release.tests.ReleaseTestCase.test_list_all
"""

if __name__ == '__main__':
    parser = argparse.ArgumentParser('client_test_run.py')
    parser.add_argument('tests', metavar='TEST', nargs='*')
    options = parser.parse_args()
    loader = unittest.TestLoader()
    if options.tests:
        suite = loader.loadTestsFromNames(options.tests)
    else:
        suite = loader.discover('pdc_client/tests', top_level_dir='.')
    result = unittest.TextTestRunner().run(suite)
    if not result.wasSuccessful():
        sys.exit(1)
