def test_filter_match_trace(self):
    t1 = (('a.py', 2), ('b.py', 3))
    t2 = (('b.py', 4), ('b.py', 5))
    t3 = (('c.py', 5), ('<unknown>', 0))
    unknown = (('<unknown>', 0),)
    f = tracemalloc.Filter(True, 'b.py', all_frames=True)
    self.assertTrue(f._match_traceback(t1))
    self.assertTrue(f._match_traceback(t2))
    self.assertFalse(f._match_traceback(t3))
    self.assertFalse(f._match_traceback(unknown))
    f = tracemalloc.Filter(True, 'b.py', all_frames=False)
    self.assertFalse(f._match_traceback(t1))
    self.assertTrue(f._match_traceback(t2))
    self.assertFalse(f._match_traceback(t3))
    self.assertFalse(f._match_traceback(unknown))
    f = tracemalloc.Filter(False, 'b.py', all_frames=True)
    self.assertFalse(f._match_traceback(t1))
    self.assertFalse(f._match_traceback(t2))
    self.assertTrue(f._match_traceback(t3))
    self.assertTrue(f._match_traceback(unknown))
    f = tracemalloc.Filter(False, 'b.py', all_frames=False)
    self.assertTrue(f._match_traceback(t1))
    self.assertFalse(f._match_traceback(t2))
    self.assertTrue(f._match_traceback(t3))
    self.assertTrue(f._match_traceback(unknown))
    f = tracemalloc.Filter(False, '<unknown>', all_frames=False)
    self.assertTrue(f._match_traceback(t1))
    self.assertTrue(f._match_traceback(t2))
    self.assertTrue(f._match_traceback(t3))
    self.assertFalse(f._match_traceback(unknown))
    f = tracemalloc.Filter(True, '<unknown>', all_frames=True)
    self.assertFalse(f._match_traceback(t1))
    self.assertFalse(f._match_traceback(t2))
    self.assertTrue(f._match_traceback(t3))
    self.assertTrue(f._match_traceback(unknown))
    f = tracemalloc.Filter(False, '<unknown>', all_frames=True)
    self.assertTrue(f._match_traceback(t1))
    self.assertTrue(f._match_traceback(t2))
    self.assertFalse(f._match_traceback(t3))
    self.assertFalse(f._match_traceback(unknown))
def test_filter_match_trace(self):
    t1 = (('a.py', 2), ('b.py', 3))
    t2 = (('b.py', 4), ('b.py', 5))
    t3 = (('c.py', 5), ('<unknown>', 0))
    unknown = (('<unknown>', 0),)
    f = tracemalloc.Filter(True, 'b.py', all_frames=True)
    self.assertTrue(f._match_traceback(t1))
    self.assertTrue(f._match_traceback(t2))
    self.assertFalse(f._match_traceback(t3))
    self.assertFalse(f._match_traceback(unknown))
    f = tracemalloc.Filter(True, 'b.py', all_frames=False)
    self.assertFalse(f._match_traceback(t1))
    self.assertTrue(f._match_traceback(t2))
    self.assertFalse(f._match_traceback(t3))
    self.assertFalse(f._match_traceback(unknown))
    f = tracemalloc.Filter(False, 'b.py', all_frames=True)
    self.assertFalse(f._match_traceback(t1))
    self.assertFalse(f._match_traceback(t2))
    self.assertTrue(f._match_traceback(t3))
    self.assertTrue(f._match_traceback(unknown))
    f = tracemalloc.Filter(False, 'b.py', all_frames=False)
    self.assertTrue(f._match_traceback(t1))
    self.assertFalse(f._match_traceback(t2))
    self.assertTrue(f._match_traceback(t3))
    self.assertTrue(f._match_traceback(unknown))
    f = tracemalloc.Filter(False, '<unknown>', all_frames=False)
    self.assertTrue(f._match_traceback(t1))
    self.assertTrue(f._match_traceback(t2))
    self.assertTrue(f._match_traceback(t3))
    self.assertFalse(f._match_traceback(unknown))
    f = tracemalloc.Filter(True, '<unknown>', all_frames=True)
    self.assertFalse(f._match_traceback(t1))
    self.assertFalse(f._match_traceback(t2))
    self.assertTrue(f._match_traceback(t3))
    self.assertTrue(f._match_traceback(unknown))
    f = tracemalloc.Filter(False, '<unknown>', all_frames=True)
    self.assertTrue(f._match_traceback(t1))
    self.assertTrue(f._match_traceback(t2))
    self.assertFalse(f._match_traceback(t3))
    self.assertFalse(f._match_traceback(unknown))