Creation of a temp file on Windows
In the try block, temp might not get assigned, so temp.name would be an error. But this is an extremely unlikely scenario.

You seem to be going out of your way to defeat the natural clean-up capability of the named temporary file:


  If delete is true (the default), the file is deleted as soon as it is closed.


Since the file is opened via a with block, it should be closed automatically at the end of the block, and automatically deleted as well, if you let it.  Therefore, you shouldn't need the try...finally at all, and you can remove the delete=False parameter from NamedTemporaryFile:

def test_read(self):
    """Test read from file"""
    import tempfile

    with tempfile.NamedTemporaryFile() as temp:
        content = 'Some data'
        temp.write(content.encode('utf-8'))
        temp.flush()
        self.assertEqual(content, b.read(Path(temp.name)))


When you open a file for reading, you can omit the r in here:


with open(path.as_posix(), 'r') as file:
   return file.read()



Finally, b is terrible name. It doesn't tell anything about the module.