def _TestLocalFile():
    import tempfile, os
    fname = tempfile.mktemp()
    data = "Hello from Python"
    test_file = LocalFile(fname, "w")
    try:
        test_file.write(data)
        test_file.close()
        # Make sure Python can read it OK.
        f = open(fname, "r")
        assert f.read() == data, "Eeek - Python could not read the data back correctly!"
        f.close()
        # For the sake of the test, try a re-init.
        test_file.init(fname, "r")
        got = str(test_file.read())
        assert got == data, got
        test_file.close()
        # Try reading in chunks.
        test_file = LocalFile(fname, "r")
        got = test_file.read(10) + test_file.read()
        assert got == data, got
        test_file.close()
        # Open the same file again for writing - this should delete the old one.
        if not os.path.isfile(fname):
            raise RuntimeError, "The file '%s' does not exist, but we are explicitly testing create semantics when it does" % (fname,)
        test_file = LocalFile(fname, "w")
        test_file.write(data)
        test_file.close()
        # Make sure Python can read it OK.
        f = open(fname, "r")
        assert f.read() == data, "Eeek - Python could not read the data back correctly after recreating an existing file!"
        f.close()

        # XXX - todo - test "a" mode!
    finally:
        os.unlink(fname)