def test_filter_traces(self):
    (snapshot, snapshot2) = create_snapshots()
    filter1 = tracemalloc.Filter(False, 'b.py')
    filter2 = tracemalloc.Filter(True, 'a.py', 2)
    filter3 = tracemalloc.Filter(True, 'a.py', 5)
    original_traces = list(snapshot.traces._traces)
    snapshot3 = snapshot.filter_traces((filter1,))
    self.assertEqual(snapshot3.traces._traces, [(0, 10, (('a.py', 2), ('b.py', 4))), (0, 10, (('a.py', 2), ('b.py', 4))), (0, 10, (('a.py', 2), ('b.py', 4))), (1, 2, (('a.py', 5), ('b.py', 4))), (3, 7, (('<unknown>', 0),))])
    self.assertEqual(snapshot.traces._traces, original_traces)
    snapshot4 = snapshot3.filter_traces((filter2, filter3))
    self.assertEqual(snapshot4.traces._traces, [(0, 10, (('a.py', 2), ('b.py', 4))), (0, 10, (('a.py', 2), ('b.py', 4))), (0, 10, (('a.py', 2), ('b.py', 4))), (1, 2, (('a.py', 5), ('b.py', 4)))])
    snapshot5 = snapshot.filter_traces(())
    self.assertIsNot(snapshot5, snapshot)
    self.assertIsNot(snapshot5.traces, snapshot.traces)
    self.assertEqual(snapshot5.traces, snapshot.traces)
    self.assertRaises(TypeError, snapshot.filter_traces, filter1)
def test_filter_traces(self):
    (snapshot, snapshot2) = create_snapshots()
    filter1 = tracemalloc.Filter(False, 'b.py')
    filter2 = tracemalloc.Filter(True, 'a.py', 2)
    filter3 = tracemalloc.Filter(True, 'a.py', 5)
    original_traces = list(snapshot.traces._traces)
    snapshot3 = snapshot.filter_traces((filter1,))
    self.assertEqual(snapshot3.traces._traces, [(0, 10, (('a.py', 2), ('b.py', 4))), (0, 10, (('a.py', 2), ('b.py', 4))), (0, 10, (('a.py', 2), ('b.py', 4))), (1, 2, (('a.py', 5), ('b.py', 4))), (3, 7, (('<unknown>', 0),))])
    self.assertEqual(snapshot.traces._traces, original_traces)
    snapshot4 = snapshot3.filter_traces((filter2, filter3))
    self.assertEqual(snapshot4.traces._traces, [(0, 10, (('a.py', 2), ('b.py', 4))), (0, 10, (('a.py', 2), ('b.py', 4))), (0, 10, (('a.py', 2), ('b.py', 4))), (1, 2, (('a.py', 5), ('b.py', 4)))])
    snapshot5 = snapshot.filter_traces(())
    self.assertIsNot(snapshot5, snapshot)
    self.assertIsNot(snapshot5.traces, snapshot.traces)
    self.assertEqual(snapshot5.traces, snapshot.traces)
    self.assertRaises(TypeError, snapshot.filter_traces, filter1)