Exemplo n.º 1
0
    def testTwoScopes(self):
        resource_tracker1 = tracking.ResourceTracker()
        with tracking.resource_tracker_scope(resource_tracker1):
            dummy_resource1 = _DummyResource("test1")

        resource_tracker2 = tracking.ResourceTracker()
        with tracking.resource_tracker_scope(resource_tracker2):
            dummy_resource2 = _DummyResource("test2")

        self.assertEqual(1, len(resource_tracker1.resources))
        self.assertEqual("test1",
                         resource_tracker1.resources[0].resource_handle)
        self.assertEqual(1, len(resource_tracker1.resources))
        self.assertEqual("test2",
                         resource_tracker2.resources[0].resource_handle)
Exemplo n.º 2
0
    def testBasic(self):
        resource_tracker = tracking.ResourceTracker()
        with tracking.resource_tracker_scope(resource_tracker):
            dummy_resource1 = _DummyResource("test1")
            dummy_resource2 = _DummyResource("test2")

        self.assertEqual(2, len(resource_tracker.resources))
        self.assertEqual("test1",
                         resource_tracker.resources[0].resource_handle)
        self.assertEqual("test2",
                         resource_tracker.resources[1].resource_handle)