def test_create_snapshot(self):
    raw_traces = [(0, 5, (('a.py', 2),))]
    with contextlib.ExitStack() as stack:
        stack.enter_context(patch.object(tracemalloc, 'is_tracing', return_value=True))
        stack.enter_context(patch.object(tracemalloc, 'get_traceback_limit', return_value=5))
        stack.enter_context(patch.object(tracemalloc, '_get_traces', return_value=raw_traces))
        snapshot = tracemalloc.take_snapshot()
        self.assertEqual(snapshot.traceback_limit, 5)
        self.assertEqual(len(snapshot.traces), 1)
        trace = snapshot.traces[0]
        self.assertEqual(trace.size, 5)
        self.assertEqual(len(trace.traceback), 1)
        self.assertEqual(trace.traceback[0].filename, 'a.py')
        self.assertEqual(trace.traceback[0].lineno, 2)
def test_create_snapshot(self):
    raw_traces = [(0, 5, (('a.py', 2),))]
    with contextlib.ExitStack() as stack:
        stack.enter_context(patch.object(tracemalloc, 'is_tracing', return_value=True))
        stack.enter_context(patch.object(tracemalloc, 'get_traceback_limit', return_value=5))
        stack.enter_context(patch.object(tracemalloc, '_get_traces', return_value=raw_traces))
        snapshot = tracemalloc.take_snapshot()
        self.assertEqual(snapshot.traceback_limit, 5)
        self.assertEqual(len(snapshot.traces), 1)
        trace = snapshot.traces[0]
        self.assertEqual(trace.size, 5)
        self.assertEqual(len(trace.traceback), 1)
        self.assertEqual(trace.traceback[0].filename, 'a.py')
        self.assertEqual(trace.traceback[0].lineno, 2)