Skip to content

Testing python cli tool using typer -- Trying to change home dir #2254

Answered by jugmac00
ajoino asked this question in Q&A
Discussion options

You must be logged in to vote

This cannot be solved by tox - tox just drives pytest or any other test runner, but does not test and also not create mocks itself.

I see a couple of options. If the path which points to ~/.config is exposed, you could mock or inject it.

You possibly could mock typer's get_app_dir, although this may cause side effects.

Finally, you could use pyfakefs which creates a fake file system for the tests only, see http://jmcgeheeiv.github.io/pyfakefs/master/usage.html

For pytest questions - and this is a pytest question - you could also visit their discord server:
https://discord.com/invite/pytest-dev

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ajoino
Comment options

Answer selected by jugmac00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants