debugpy/tests/__init__.py
Eric Snow 10af45bccc
A bunch of cleanup/lint fixes for the system tests. (#625)
The system tests have a number of minor formatting and structural issues that would be better to clean up sooner rather than later. This PR addresses nearly all of them.
2018-07-09 17:14:57 -06:00

46 lines
1.4 KiB
Python

from __future__ import absolute_import
import os
import os.path
import sys
import unittest
# Importing "ptvsd" here triggers the vendoring code before any vendored
# code ever gets imported.
import ptvsd # noqa
from ptvsd._vendored import list_all as vendored
TEST_ROOT = os.path.abspath(os.path.dirname(__file__)) # noqa
RESOURCES_ROOT = os.path.join(TEST_ROOT, 'resources') # noqa
PROJECT_ROOT = os.path.dirname(TEST_ROOT) # noqa
VENDORED_ROOTS = vendored(resolve=True) # noqa
def skip_py2(decorated=None):
if sys.version_info[0] > 2:
return decorated
msg = 'not tested under Python 2'
if decorated is None:
raise unittest.SkipTest(msg)
else:
decorator = unittest.skip(msg)
return decorator(decorated)
if sys.version_info[0] == 2:
# Hack alert!!!
class SkippingTestSuite(unittest.TestSuite):
def __init__(self, tests=()):
if tests and type(tests[0]).__name__ == 'ModuleImportFailure':
_, exc, _ = sys.exc_info()
if isinstance(exc, unittest.SkipTest):
from unittest.loader import _make_failed_load_tests
suite = _make_failed_load_tests(
tests[0]._testMethodName,
exc,
type(self),
)
tests = tuple(suite)
unittest.TestSuite.__init__(self, tests)
unittest.TestLoader.suiteClass = SkippingTestSuite