Efren Efren - 6 months ago 38
Python Question

os.path.join fails with "TypeError: object of type 'LocalPath' has no len()"

This error appeared when trying to use the 'tmpdir' in a pytest test.

TypeError: object of type 'LocalPath' has no len()


'tmpdir' is of type <class 'py._path.local.LocalPath'>, just wrap 'tmpdir' in a string when passing to os.path.join


os.path.join(str(tmpdir, 'my_test_file.txt')