Skip to content

test: Use pathlib over os.path #28362

@maflcko

Description

@maflcko

Motivation

os.path is quite verbose in the tests and is problematic, because strings can be appended to it, for example it is possible to type:

>>> os.path.join('a/') + '/../b.txt'
'a//../b.txt'

This may lead to issues down the line when the tests are run on Windows and expect a different path separator.

Possible solution

While some uses of os.path are hard(er) to replace, with questionable benefits, I think removing the use of TestNode.datadir and replacing it with TestNode.datadir_path is a good first step.

Useful Skills

  • Compile Bitcoin Core and run the python tests
  • Basic familiarity with the Bitcoin Core RPC, and the python tests
  • os.path and pathlib knowledge

Guidance for new contributors

Want to work on this issue?

For guidance on contributing, please read CONTRIBUTING.md before opening your pull request.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions