File: test_pydevdio.py

package info (click to toggle)
pydevd 3.3.0%2Bds-4
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 13,892 kB
  • sloc: python: 77,508; cpp: 1,869; sh: 368; makefile: 50; ansic: 4
file content (37 lines) | stat: -rw-r--r-- 1,195 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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)