diff --git a/tests/pattern.py b/tests/pattern.py deleted file mode 100644 index 3f84f766..00000000 --- a/tests/pattern.py +++ /dev/null @@ -1,4 +0,0 @@ -ANY = None -Path = None -Regex = None -Is = None diff --git a/tests/print.py b/tests/print.py deleted file mode 100644 index bcefef3e..00000000 --- a/tests/print.py +++ /dev/null @@ -1,58 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See LICENSE in the project root -# for license information. - -from __future__ import absolute_import, print_function, unicode_literals - -"""When imported using from, this module effectively overrides the print() built-in -with a synchronized version that also adds a timestamp. - -Because tests can run in parallel, all modules that can be invoked from test code, -and that need to print, should do:: - - from tests import print - -Each call to print() is then atomic - i.e. it will not interleave with any other print. -If a sequence of several print calls must be atomic, lock explicitly:: - - with print: - print('fizz') - print('bazz') -""" - -import sys -import types - -from ptvsd.common import fmt, singleton, timestamp - - -# The class of the module object for this module. -class Printer(singleton.ThreadSafeSingleton, types.ModuleType): - def __init__(self): - # Set self up as a proper module, and copy globals. - # types must be re-imported, because globals aren't there yet at this point. - import types - types.ModuleType.__init__(self, __name__) - self.__dict__.update(sys.modules[__name__].__dict__) - - @singleton.autolocked_method - def __call__(self, *args, **kwargs): - """Like builtin print(), but synchronized across multiple threads, - and adds a timestamp. - """ - with self: - timestamped = kwargs.pop('timestamped', True) - t = timestamp.current() if timestamped else None - if t is not None: - t = '@%09.6f:' % t - args = (t,) + args - print(*args, **kwargs) - - def f(self, format_string, *args, **kwargs) : - """Same as print(fmt(...)). - """ - return self(fmt(format_string, *args, **kwargs)) - - -# Replace the standard module object for this module with a Printer object. -sys.modules[__name__] = Printer() diff --git a/tests/ptvsd/common/test_messaging.py b/tests/ptvsd/common/test_messaging.py index 02c10a73..3913ffbd 100644 --- a/tests/ptvsd/common/test_messaging.py +++ b/tests/ptvsd/common/test_messaging.py @@ -17,7 +17,7 @@ import socket import threading import time -from ptvsd.common import fmt, messaging +from ptvsd.common import log, messaging from tests.patterns import some @@ -576,14 +576,14 @@ class TestJsonMessageChannel(object): class Handlers(object): def stackTrace_request(self, request): - print(request.arguments["AAA"]) - print(request.arguments["AAA"]["BBB"]) + request.arguments["AAA"] + request.arguments["AAA"]["BBB"] def request(self, request): - print(request.arguments["CCC"]) + request.arguments["CCC"] def pause_request(self, request): - print(request.arguments["DDD"]) + request.arguments["DDD"] input, input_exhausted = self.iter_with_event(REQUESTS) output = [] @@ -732,9 +732,7 @@ class TestJsonMessageChannel(object): # Spin until we receive "done", and also get responses to all requests. requests_sent = types.count("request") - print( - fmt("{0} waiting for {1} responses ...", self.name, requests_sent) - ) + log.info("{0} waiting for {1} responses...", self.name, requests_sent) while True: with self.lock: if self.done: diff --git a/tests/ptvsd/server/test_parse_args.py b/tests/ptvsd/server/test_parse_args.py index e9a1e6fb..986e7e99 100644 --- a/tests/ptvsd/server/test_parse_args.py +++ b/tests/ptvsd/server/test_parse_args.py @@ -6,6 +6,7 @@ from __future__ import absolute_import, print_function, unicode_literals import pytest +from ptvsd.common import log from ptvsd.common.compat import reload from ptvsd.server import options, __main__ from tests.patterns import some @@ -64,7 +65,7 @@ def test_targets(target_kind, client, wait, nodebug, multiproc, extra): else: extra = [] - print(args) + log.debug("args = {0!r}", args) reload(options) rest = __main__.parse(args) assert list(rest) == extra diff --git a/tests/ptvsd/server/test_step.py b/tests/ptvsd/server/test_step.py index a50b0d06..58b2d9e3 100644 --- a/tests/ptvsd/server/test_step.py +++ b/tests/ptvsd/server/test_step.py @@ -24,7 +24,6 @@ def test_set_next_statement(pyfile, start_method, run_as): func() line_numbers = code_to_debug.lines - print(line_numbers) with debug.Session() as session: session.initialize( diff --git a/tests/tests/test_timeline.py b/tests/tests/test_timeline.py index 62409f48..e7354e34 100644 --- a/tests/tests/test_timeline.py +++ b/tests/tests/test_timeline.py @@ -452,14 +452,14 @@ def test_unobserved(make_timeline, daemon): worker_can_proceed.wait() worker_can_proceed.clear() timeline.record_event(messages.event('dum', {})) - print('dum') + log.debug('dum') worker_can_proceed.wait() timeline.record_event(messages.event('dee', {})) - print('dee') + log.debug('dee') timeline.record_event(messages.event('dum', {})) - print('dum') + log.debug('dum') timeline.freeze() assert timeline.is_frozen