Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Comments

add stderr message if env file not found#17

Open
Amertz08 wants to merge 1 commit intoquiqua:masterfrom
Amertz08:feature/warn-file-not-found
Open

add stderr message if env file not found#17
Amertz08 wants to merge 1 commit intoquiqua:masterfrom
Amertz08:feature/warn-file-not-found

Conversation

@Amertz08
Copy link

This PR should add a simple stderr message if the env file is not actually found.


def _check_exists(filename):
if not os.path.exists(filename):
sys.stderr.write("Env file not found: %s\n" % filename)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might need a sys.stderr.flush() here. I'm not entirely sure.

load_dotenv(dotenv_path=env_file, override=True)


def _check_exists(filename):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall the plugin just print warnings to the user or completely stop the execution if something is not configured correctly?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also do you know who other py.test plugins behave in such a scenario?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not know of any other plugins that have a similar scenario. I'll try and look some up.

The way I implemented it continues execution but prints to stderr (which should highlight for certain terminals). load_dotenv does nothing if it cannot find the file. So it is currently silently failing. The warning should make it more obvious.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants