    def setUp(self, request):
        self.db_path = tempfile.NamedTemporaryFile(
            prefix='tmp_b2_tests_%s__' % (request.node.name,), delete=True
        ).name
        try:
            os.unlink(self.db_path)
        except OSError:
            pass
        self.home = tempfile.mkdtemp()

        yield
        for cleanup_method in [lambda: os.unlink(self.db_path), lambda: shutil.rmtree(self.home)]:
            try:
                cleanup_method
            except OSError:
                pass
The software checks the state of a resource before using that resource, but the resource's state can change between the check and the use in a way that invalidates the results of the check. This can cause the software to perform invalid actions when the resource is in an unexpected state.