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

os.path, pytest, python

Solution

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

example:

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

Problem

This error appeared when trying to use the 'tmpdir' in a pytest test. TypeError: object of type 'LocalPath' has no len()

Original source