From c1534ba9870d62f0a9f988a7dd3c88ec28b75860 Mon Sep 17 00:00:00 2001 From: Robert Brewer Date: Wed, 10 Jul 2019 18:12:31 -0700 Subject: [PATCH] Version bump. --- setup.py | 2 +- src/diagnose/probes.py | 6 +----- tests/test_probes.py | 37 +++++++++++-------------------------- 3 files changed, 13 insertions(+), 32 deletions(-) diff --git a/setup.py b/setup.py index 530279b..6871879 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup( name="diagnose", - version="2.0.0", + version="2.1.0", author="Robert Brewer", author_email="dev@crunch.io", description="A library for instrumenting Python code at runtime.", diff --git a/src/diagnose/probes.py b/src/diagnose/probes.py index 9a799dc..95a1458 100644 --- a/src/diagnose/probes.py +++ b/src/diagnose/probes.py @@ -226,11 +226,7 @@ def probe_wrapper(*args, **kwargs): if instruments_by_event["return"]: end = time.time() elapsed = end - start - _locals.update({ - "result": result, - "end": end, - "elapsed": elapsed, - }) + _locals.update({"result": result, "end": end, "elapsed": elapsed}) for instrument in instruments_by_event["return"]: try: diff --git a/tests/test_probes.py b/tests/test_probes.py index abba4d2..0481b30 100644 --- a/tests/test_probes.py +++ b/tests/test_probes.py @@ -35,9 +35,7 @@ class TestReturnEvent(ProbeTestCase): def test_return_event_result(self): - with self.probe( - "test", "do", "diagnose.test_fixtures.Thing.do", "result" - ) as p: + with self.probe("test", "do", "diagnose.test_fixtures.Thing.do", "result") as p: result = Thing().do("ok") assert result == "" @@ -60,10 +58,7 @@ def test_return_event_elapsed(self): def test_return_event_locals(self): with self.probe( - "test", - "do", - "diagnose.test_fixtures.Thing.do", - "sorted(locals().keys())", + "test", "do", "diagnose.test_fixtures.Thing.do", "sorted(locals().keys())" ) as p: result = Thing().do("ok") @@ -122,7 +117,9 @@ def test_call_event_elapsed(self): "test", "do", "diagnose.test_fixtures.Thing.do", "elapsed", event="call" ) as p: errs = [] - p.instruments.values()[0].handle_error = lambda probe: errs.append(sys.exc_info()[1].message) + p.instruments.values()[0].handle_error = lambda probe: errs.append( + sys.exc_info()[1].message + ) result = Thing().do("ok") assert result == "" @@ -138,7 +135,7 @@ def test_call_event_locals(self): "do", "diagnose.test_fixtures.Thing.do", "sorted(locals().keys())", - event="call" + event="call", ) as p: result = Thing().do("ok") @@ -146,18 +143,7 @@ def test_call_event_locals(self): # The probe MUST have logged an entry assert p.instruments.values()[0].results == [ - ( - [], - [ - "arg", - "args", - "frame", - "kwargs", - "now", - "self", - "start", - ], - ) + ([], ["arg", "args", "frame", "kwargs", "now", "self", "start"]) ] def test_call_event_locals_frame(self): @@ -216,7 +202,9 @@ def test_end_event_exception_in_value(self): try: errs = [] old_handle_error = diagnose.manager.handle_error - diagnose.manager.handle_error = lambda probe, instr: errs.append(sys.exc_info()[1].message) + diagnose.manager.handle_error = lambda probe, instr: errs.append( + sys.exc_info()[1].message + ) probe.start() probe.instruments["instrument1"] = i = ProbeTestInstrument( expires=datetime.datetime.utcnow() + datetime.timedelta(minutes=10), @@ -425,10 +413,7 @@ def test_probe_nonfunc(self): def test_patch_staticmethod(self): with self.probe( - "test", - "quantile", - "diagnose.test_fixtures.Thing.static", - "result", + "test", "quantile", "diagnose.test_fixtures.Thing.static", "result" ) as p: assert Thing().static() == 15 assert p.instruments.values()[0].results == [([], 15)]