Skip to content

Commit

Permalink
Merge 2d48d3c into 58011a3
Browse files Browse the repository at this point in the history
  • Loading branch information
yakobu committed Apr 21, 2019
2 parents 58011a3 + 2d48d3c commit d73862a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 21 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Setup file for handling packaging and distribution."""
from setuptools import setup

__version__ = "2.4.0"
__version__ = "2.4.1"

setup(
name="ipdbugger",
Expand Down
49 changes: 30 additions & 19 deletions tests/test_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from __future__ import absolute_import

import pytest
from IPython.utils.capture import capture_output

from ipdbugger import debug

Expand All @@ -19,7 +18,8 @@ def test_debugging_raising_function():
def should_raise():
raise Exception()

with capture_output(), patch('bdb.Bdb.set_trace') as set_trace:
with patch('IPython.terminal.debugger.TerminalPdb.__init__'), \
patch('bdb.Bdb.set_trace') as set_trace:
should_raise()
assert set_trace.called

Expand All @@ -33,7 +33,8 @@ def should_raise(self):
a = A()
a.should_raise = debug(a.should_raise)

with capture_output(), patch('bdb.Bdb.set_trace') as set_trace:
with patch('IPython.terminal.debugger.TerminalPdb.__init__'), \
patch('bdb.Bdb.set_trace') as set_trace:
a.should_raise()
assert set_trace.called

Expand All @@ -45,7 +46,8 @@ def test_debugging_function_twice():
def should_raise():
raise Exception()

with capture_output(), patch('bdb.Bdb.set_trace') as set_trace:
with patch('IPython.terminal.debugger.TerminalPdb.__init__'), \
patch('bdb.Bdb.set_trace') as set_trace:
should_raise()
assert set_trace.called_once

Expand All @@ -56,7 +58,8 @@ def test_debugging_non_raising_function():
def non_raising_function():
pass

with capture_output(), patch('bdb.Bdb.set_trace') as set_trace:
with patch('IPython.terminal.debugger.TerminalPdb.__init__'), \
patch('bdb.Bdb.set_trace') as set_trace:
non_raising_function()
assert not set_trace.called

Expand All @@ -73,11 +76,13 @@ def second_method(self):

debugged_object = DebuggedClass()

with capture_output(), patch('bdb.Bdb.set_trace') as set_trace:
with patch('IPython.terminal.debugger.TerminalPdb.__init__'), \
patch('bdb.Bdb.set_trace') as set_trace:
debugged_object.first_method()
assert set_trace.called

with capture_output(), patch('bdb.Bdb.set_trace') as set_trace:
with patch('IPython.terminal.debugger.TerminalPdb.__init__'), \
patch('bdb.Bdb.set_trace') as set_trace:
debugged_object.second_method()
assert set_trace.called

Expand Down Expand Up @@ -122,7 +127,8 @@ def func():

func = debug(func, catch_exception=AssertionError)

with capture_output(), patch('bdb.Bdb.set_trace') as set_trace:
with patch('IPython.terminal.debugger.TerminalPdb.__init__'), \
patch('bdb.Bdb.set_trace') as set_trace:
func()
assert set_trace.called

Expand Down Expand Up @@ -162,7 +168,8 @@ def func():

func = debug(func)

with capture_output(), patch('bdb.Bdb.set_trace') as set_trace:
with patch('IPython.terminal.debugger.TerminalPdb.__init__'), \
patch('bdb.Bdb.set_trace') as set_trace:
func()
assert set_trace.called

Expand All @@ -176,7 +183,8 @@ def func():
except ValueError:
raise

with capture_output(), patch('bdb.Bdb.set_trace') as set_trace:
with patch('IPython.terminal.debugger.TerminalPdb.__init__'), \
patch('bdb.Bdb.set_trace') as set_trace:
func()
assert set_trace.called_once

Expand Down Expand Up @@ -209,7 +217,8 @@ def func():
except KeyError:
pass

with capture_output(), patch('bdb.Bdb.set_trace') as set_trace:
with patch('IPython.terminal.debugger.TerminalPdb.__init__'), \
patch('bdb.Bdb.set_trace') as set_trace:
func()
assert set_trace.call_count == 0

Expand All @@ -223,7 +232,8 @@ def func():
if raise_exc:
raise ValueError()

with capture_output(), patch('bdb.Bdb.set_trace') as set_trace:
with patch('IPython.terminal.debugger.TerminalPdb.__init__'), \
patch('bdb.Bdb.set_trace') as set_trace:
func()
assert set_trace.called_once

Expand Down Expand Up @@ -253,8 +263,8 @@ def func_upper():

func_upper = debug(func_upper, depth=0)

with capture_output(), patch('bdb.Bdb.set_trace',
SaveFuncName()) as name_saver:
with patch('IPython.terminal.debugger.TerminalPdb.__init__'), \
patch('bdb.Bdb.set_trace', SaveFuncName()) as name_saver:
func_upper()
assert name_saver.func_name == "func_upper"

Expand All @@ -275,8 +285,8 @@ def func_upper():

func_upper = debug(func_upper, depth=1)

with capture_output(), patch('bdb.Bdb.set_trace',
SaveFuncName()) as name_saver:
with patch('IPython.terminal.debugger.TerminalPdb.__init__'), \
patch('bdb.Bdb.set_trace', SaveFuncName()) as name_saver:
func_upper()
assert name_saver.func_name == "func_middle"

Expand All @@ -297,8 +307,8 @@ def func_upper():

func_upper = debug(func_upper, depth=-1)

with capture_output(), patch('bdb.Bdb.set_trace',
SaveFuncName()) as name_saver:
with patch('IPython.terminal.debugger.TerminalPdb.__init__'), \
patch('bdb.Bdb.set_trace', SaveFuncName()) as name_saver:
func_upper()
assert name_saver.func_name == "func_lowest"

Expand All @@ -321,6 +331,7 @@ def test_using_debug_as_decorator_with_kwargs():
def func():
raise ValueError()

with capture_output(), patch('bdb.Bdb.set_trace') as set_trace:
with patch('IPython.terminal.debugger.TerminalPdb.__init__'), \
patch('bdb.Bdb.set_trace') as set_trace:
func()
assert set_trace.called
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ extras = dev
commands =
flake8 setup.py ipdbugger
pylint setup.py ipdbugger
pytest -s
pytest

[pytest]
testpaths = tests/
Expand Down

0 comments on commit d73862a

Please sign in to comment.