MCPcopy Index your code
hub / github.com/prometheus/client_python / test_function_decorator

Method test_function_decorator

tests/test_core.py:65–85  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

63 self.assertRaises(ValueError, self.counter.inc, -1)
64
65 def test_function_decorator(self):
66 @self.counter.count_exceptions(ValueError)
67 def f(r):
68 if r:
69 raise ValueError
70 else:
71 raise TypeError
72
73 self.assertEqual((["r"], None, None, None), getargspec(f))
74
75 try:
76 f(False)
77 except TypeError:
78 pass
79 self.assertEqual(0, self.registry.get_sample_value('c_total'))
80
81 try:
82 f(True)
83 except ValueError:
84 pass
85 self.assertEqual(1, self.registry.get_sample_value('c_total'))
86
87 def test_block_decorator(self):
88 with self.counter.count_exceptions():

Callers

nothing calls this directly

Calls 3

getargspecFunction · 0.90
get_sample_valueMethod · 0.80
fFunction · 0.50

Tested by

no test coverage detected