Skip to content

Commit

Permalink
Remove stdout switch at start, fix pytest_wdb
Browse files Browse the repository at this point in the history
  • Loading branch information
paradoxxxzero committed May 9, 2016
1 parent 8c47a13 commit 1f3fbf8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
3 changes: 0 additions & 3 deletions client/wdb/__init__.py
Expand Up @@ -242,10 +242,7 @@ def index_imports(self):

def index(self):
self._importmagic_index = importmagic.SymbolIndex()
# Prevent stdout pollution
old_stdout, sys.stdout = sys.stdout, StringIO()
self._importmagic_index.build_index(sys.path)
sys.stdout = old_stdout

Thread(target=index, args=(self,)).start()

Expand Down
16 changes: 8 additions & 8 deletions pytest_wdb/test_wdb.py
Expand Up @@ -44,26 +44,26 @@ def run(self):


def test_ok(testdir):
testdir.makepyfile('''
p = testdir.makepyfile('''
def test_run():
print('Test has been run')
''')
with FakeWdbServer():
result = testdir.runpytest('--wdb')
result = testdir.runpytest_inprocess('--wdb', p)
result.stdout.fnmatch_lines([
'plugins:*wdb*'
])
assert result.ret == 0


def test_ok_run_once(testdir):
testdir.makepyfile('''
p = testdir.makepyfile('''
def test_run():
print('Test has been run')
''')

with FakeWdbServer():
result = testdir.runpytest('--wdb', '-s')
result = testdir.runpytest_inprocess('--wdb', '-s', p)

assert len([line for line in result.stdout.lines
if line == 'test_ok_run_once.py Test has been run']) == 1
Expand All @@ -73,26 +73,26 @@ def test_run():
# Todo implement fake wdb server

def test_fail_run_once(testdir):
testdir.makepyfile('''
p = testdir.makepyfile('''
def test_run():
print('Test has been run')
assert 0
''')
with FakeWdbServer(stops=True):
result = testdir.runpytest('--wdb', '-s')
result = testdir.runpytest_inprocess('--wdb', '-s', p)
assert len([line for line in result.stdout.lines
if line == 'test_fail_run_once.py Test has been run']) == 1
assert result.ret == 1


def test_error_run_once(testdir):
testdir.makepyfile('''
p = testdir.makepyfile('''
def test_run():
print('Test has been run')
1/0
''')
with FakeWdbServer(stops=True):
result = testdir.runpytest('--wdb', '-s')
result = testdir.runpytest_inprocess('--wdb', '-s', p)
assert len([line for line in result.stdout.lines
if line == 'test_error_run_once.py Test has been run']) == 1
assert result.ret == 1

0 comments on commit 1f3fbf8

Please sign in to comment.