Tests for attaching by host names (#613)

* Attach tests
* linter issues
* Disable test
This commit is contained in:
Don Jayamanne 2018-07-07 00:11:14 -07:00 committed by GitHub
parent 8d140b2d03
commit 2bc5b2c976
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 86 additions and 3 deletions

View file

@ -378,7 +378,7 @@ class BreakpointTests(VSCFlowTest, unittest.TestCase):
self.assertIn('2 4 4', out)
self.assertIn('ka-boom', err)
# @unittest.skip('not working right')
@unittest.skip('not working right #614')
def test_exception_breakpoints(self):
self.vsc.PRINT_RECEIVED_MESSAGES = True
done, script = self._set_lock('h')

View file

@ -21,8 +21,8 @@ PORT = 9876
CONNECT_TIMEOUT = 3.0
DELAY_WAITING_FOR_SOCKETS = 1.0
DebugInfo = namedtuple('DebugInfo', 'port starttype argv filename modulename env cwd attachtype') # noqa
DebugInfo.__new__.__defaults__ = (9876, 'launch', []) + ((None, ) * (len(DebugInfo._fields) - 3)) # noqa
DebugInfo = namedtuple('DebugInfo', 'host port starttype argv filename modulename env cwd attachtype') # noqa
DebugInfo.__new__.__defaults__ = ('localhost', 9876, 'launch', []) + ((None, ) * (len(DebugInfo._fields) - 4)) # noqa
Debugger = namedtuple('Debugger', 'session adapter')

View file

@ -0,0 +1,83 @@
import os
import os.path
import socket
from . import (_strip_newline_output_events, lifecycle_handshake,
LifecycleTestsBase, DebugInfo, ROOT, PORT)
TEST_FILES_DIR = os.path.join(ROOT, 'tests', 'resources', 'system_tests',
'test_basic')
class RemoteTests(LifecycleTestsBase):
def run_test_attach(self, debug_info):
options = {"debugOptions": ["RedirectOutput"]}
with self.start_debugging(debug_info) as dbg:
(_, _, _, _, _, _) = lifecycle_handshake(
dbg.session, debug_info.starttype, options=options)
received = list(_strip_newline_output_events(dbg.session.received))
self.assert_contains(
received,
[
self.new_event("output", category="stdout", output="yes"),
self.new_event("output", category="stderr", output="no"),
],
)
class AttachFileTests(RemoteTests):
def test_attach_localhost(self):
filename = os.path.join(TEST_FILES_DIR, 'test_output',
'attach_output.py')
cwd = os.path.dirname(filename)
argv = ['localhost', str(PORT)]
self.run_test_attach(
DebugInfo(
filename=filename,
attachtype='import',
cwd=cwd,
starttype='attach',
argv=argv))
def test_attach_127001(self):
filename = os.path.join(TEST_FILES_DIR, 'test_output',
'attach_output.py')
cwd = os.path.dirname(filename)
argv = ['127.0.0.1', str(PORT)]
self.run_test_attach(
DebugInfo(
filename=filename,
attachtype='import',
cwd=cwd,
starttype='attach',
argv=argv))
def test_attach_0000(self):
filename = os.path.join(TEST_FILES_DIR, 'test_output',
'attach_output.py')
cwd = os.path.dirname(filename)
argv = ['0.0.0.0', str(PORT)]
self.run_test_attach(
DebugInfo(
filename=filename,
attachtype='import',
cwd=cwd,
starttype='attach',
argv=argv))
def test_attach_byip(self):
filename = os.path.join(TEST_FILES_DIR, 'test_output',
'attach_output.py')
cwd = os.path.dirname(filename)
argv = ['0.0.0.0', str(PORT)]
ip = socket.gethostbyname(socket.gethostname())
self.run_test_attach(
DebugInfo(
filename=filename,
attachtype='import',
host=ip,
cwd=cwd,
starttype='attach',
argv=argv))