My dotfiles
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

65 строки
1.5 KiB

  1. # Copyright (c) Microsoft Corporation. All rights reserved.
  2. # Licensed under the MIT License.
  3. import os
  4. import sys
  5. def parse_argv():
  6. """Parses arguments for use with the test launcher.
  7. Arguments are:
  8. 1. Working directory.
  9. 2. Test runner, `pytest` or `nose`
  10. 3. Rest of the arguments are passed into the test runner.
  11. """
  12. return (sys.argv[1], sys.argv[2], sys.argv[3:])
  13. def exclude_current_file_from_debugger():
  14. # Load the debugger package
  15. try:
  16. import ptvsd
  17. import ptvsd.debugger as vspd
  18. vspd.DONT_DEBUG.append(os.path.normcase(__file__))
  19. except:
  20. traceback.print_exc()
  21. print('''
  22. Internal error detected. Please copy the above traceback and report at
  23. https://github.com/Microsoft/vscode-python/issues/new
  24. Press Enter to close. . .''')
  25. try:
  26. raw_input()
  27. except NameError:
  28. input()
  29. sys.exit(1)
  30. def run(cwd, testRunner, args):
  31. """Runs the test
  32. cwd -- the current directory to be set
  33. testRunner -- test runner to be used `pytest` or `nose`
  34. args -- arguments passed into the test runner
  35. """
  36. sys.path[0] = os.getcwd()
  37. os.chdir(cwd)
  38. try:
  39. if testRunner == 'pytest':
  40. import pytest
  41. pytest.main(args)
  42. else:
  43. import nose
  44. nose.run(argv=args)
  45. sys.exit(0)
  46. finally:
  47. pass
  48. if __name__ == '__main__':
  49. exclude_current_file_from_debugger()
  50. cwd, testRunner, args = parse_argv()
  51. run(cwd, testRunner, args)