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

chore: pytest hacking #2606

Merged
merged 12 commits into from
Feb 27, 2024
Merged

chore: pytest hacking #2606

merged 12 commits into from
Feb 27, 2024

Conversation

tychoish
Copy link
Contributor

@tychoish tychoish commented Feb 7, 2024

  • ran black over the code
  • added an env setting
  • did a little light refactoring on the dbt tests
  • moving some files around

@tychoish tychoish requested a review from talagluck February 7, 2024 16:19
Copy link
Contributor

@talagluck talagluck left a comment

Choose a reason for hiding this comment

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

lgtm, just one question

Comment on lines +19 to +31
@contextlib.contextmanager
def env(key: str, val: str):
prev = os.getenv(key)

os.environ[key] = val

try:
yield
finally:
if prev is None:
del os.environ[key]
else:
os.environ[key] = prev
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you explain the need for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

environment variables can either be set, or unset, or set to the empty string, (which is sort of ambiguous.) and the context manager just means that you can have a with block where the environment variable is set to one thing. and then is restored to its previous state when you exit the block

@tychoish tychoish enabled auto-merge (squash) February 8, 2024 12:59
Copy link
Contributor

@talagluck talagluck left a comment

Choose a reason for hiding this comment

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

It looks like pytest is failing but otherwise, assuming no merge conflicts with the latest dbt test PR, this looks good to me.

@tychoish tychoish merged commit ee80661 into main Feb 27, 2024
25 checks passed
@tychoish tychoish deleted the tycho/python-hacking branch February 27, 2024 02:01
tychoish added a commit that referenced this pull request Feb 28, 2024
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

Successfully merging this pull request may close these issues.

2 participants