Files
Elizaveta Shashkova 626a14835a IDEA-CR-53093: PY-37226 Revert pydev prefix for test directories
GitOrigin-RevId: 3d4abb05167e85cb44720e36d0fa3b949f199f30
2019-10-08 12:33:08 +00:00

37 lines
1.2 KiB
Python

import sys
import os
import unittest
class Test(unittest.TestCase):
def test_it(self):
#make it as if we were executing from the directory above this one (so that we can use jycompletionserver
#without the need for it being in the pythonpath)
#(twice the dirname to get the previous level from this file.)
import test_pydevdio #@UnresolvedImport - importing itself
ADD_TO_PYTHONPATH = os.path.join(os.path.dirname(os.path.dirname(test_pydevdio.__file__)))
sys.path.insert(0, ADD_TO_PYTHONPATH)
try:
from _pydevd_bundle import pydevd_io
original = sys.stdout
try:
sys.stdout = pydevd_io.IOBuf()
print('foo')
print('bar')
self.assertEqual('foo\nbar\n', sys.stdout.getvalue()) #@UndefinedVariable
print('ww')
print('xx')
self.assertEqual('ww\nxx\n', sys.stdout.getvalue()) #@UndefinedVariable
finally:
sys.stdout = original
finally:
#remove it to leave it ok for other tests
sys.path.remove(ADD_TO_PYTHONPATH)