Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.env not loaded when running built-in tests #2836

Open
ReubenFrankel opened this issue Jan 21, 2025 · 3 comments
Open

.env not loaded when running built-in tests #2836

ReubenFrankel opened this issue Jan 21, 2025 · 3 comments

Comments

@ReubenFrankel
Copy link
Contributor

ReubenFrankel commented Jan 21, 2025

I think I'm missing something since I can confirm that the .env is loaded when running tests:

if "parse_env_config" not in kwargs:
kwargs["parse_env_config"] = True

and then

if parse_env_config:
self.logger.info("Parsing env var for settings config...")
config_dict.update(self._env_var_config)

and

@classproperty
def _env_var_config(cls) -> dict[str, t.Any]: # noqa: N805
"""Return any config specified in environment variables.
Variables must match the convention "<PLUGIN_NAME>_<SETTING_NAME>",
all uppercase with dashes converted to underscores.
Returns:
Dictionary of configuration parsed from the environment.
"""
config_jsonschema = cls.config_jsonschema
cls.append_builtin_config(config_jsonschema)
return parse_environment_config(config_jsonschema, cls._env_var_prefix)

If you run pytest with the -s flag, you should be able to see something like

2025-01-21 11:09:25,719 | INFO     | singer_sdk.configuration._dict_config | Parsing 'account_id' config from env variable 'TAP_CHECKLY_ACCOUNT_ID'.
2025-01-21 11:09:25,719 | INFO     | singer_sdk.configuration._dict_config | Parsing 'token' config from env variable 'TAP_CHECKLY_TOKEN'.

even though the env vars are not set in the shell where this is running.

Originally posted by @edgarrmondragon in #2835 (comment)

@ReubenFrankel
Copy link
Contributor Author

ReubenFrankel commented Jan 21, 2025

This is on the latest version (v0.43.1)

Image

@ReubenFrankel
Copy link
Contributor Author

So not sure why find_dotenv returns '' here...

Image

@ReubenFrankel
Copy link
Contributor Author

It appears it is trying to resolve a .env from the file in which load_dotenv was called:

Image

I feel like it's probably going through this path for you @edgarrmondragon

Image

whereas mine jumps to the else condition (see above).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant