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

Refactor cli tests to rely on large terminal #1253

Merged
merged 7 commits into from
Nov 22, 2022
Merged

Conversation

feluelle
Copy link
Member

@feluelle feluelle commented Nov 15, 2022

Instead of changing the stdout via get_stdout, we just set the TERMINAL_WIDTH to a very large number to avoid new lines. The configuration has been copied from https://github.com/tiangolo/typer/blob/master/scripts/test.sh

EDIT:

I have also created tiangolo/typer#509 to fix that in typer.

@@ -99,6 +99,7 @@ jobs:
env:
AIRFLOW__CORE__XCOM_BACKEND: astro.custom_backend.astro_custom_backend.AstroCustomXcomBackend
AIRFLOW__ASTRO_SDK__STORE_DATA_LOCAL_DEV: True
TERMINAL_WIDTH: 3000
Copy link
Collaborator

Choose a reason for hiding this comment

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

@feluelle do you see any downsides to increasing the terminal width to this value?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not really. The advantage is that we can start having tests checking for explicit new lines whereas if we don't set the terminal width we need to either replace the new lines always, but then we cannot check for new lines in output, to make it consistent or check for the new lines in conjunction with the actual string/output. The question is what would be ideal terminal width be? I think there is none, hence we are setting it to a large number to avoid terminal doing terminal things.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds like a good plan! I'm happy for us to merge this once the checks are passing!

Copy link
Member Author

Choose a reason for hiding this comment

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

It seems setting TERMINAL_WIDTH does not change reflect the terminal size in the tests. I can reproduce on a small local terminal :(

Copy link
Member Author

Choose a reason for hiding this comment

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

I found the issue 4a9811b

@feluelle feluelle marked this pull request as draft November 15, 2022 16:24
@feluelle feluelle marked this pull request as ready for review November 17, 2022 14:41
@codecov
Copy link

codecov bot commented Nov 17, 2022

Codecov Report

Base: 93.96% // Head: 94.00% // Increases project coverage by +0.03% 🎉

Coverage data is based on head (90765b1) compared to base (4134d6b).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1253      +/-   ##
==========================================
+ Coverage   93.96%   94.00%   +0.03%     
==========================================
  Files          18       18              
  Lines         613      617       +4     
  Branches       69       69              
==========================================
+ Hits          576      580       +4     
  Misses         22       22              
  Partials       15       15              
Impacted Files Coverage Δ
sql-cli/sql_cli/__main__.py 97.22% <100.00%> (ø)
sql-cli/sql_cli/connections.py 100.00% <100.00%> (ø)
sql-cli/sql_cli/run_dag.py 96.73% <100.00%> (ø)
sql-cli/sql_cli/utils/rich.py 88.23% <100.00%> (+3.61%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@pankajkoti pankajkoti left a comment

Choose a reason for hiding this comment

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

Looks good to me, have a minor question inline above using the same utils function across other usages of rich.print across other modules.

sql-cli/sql_cli/utils/rich.py Show resolved Hide resolved
Instead of changing the stdout via get_stdout, we just set the TERMINAL_WIDTH to a very large number to avoid new lines. The configuration has been copied from https://github.com/tiangolo/typer/blob/master/scripts/test.sh
..as this is a 1:1 copy of rich interface
@feluelle feluelle merged commit 7763fd2 into main Nov 22, 2022
@feluelle feluelle deleted the refactor/sql-cli-cli-tests branch November 22, 2022 11:29
feluelle added a commit that referenced this pull request Nov 23, 2022
…1298)

# Description

## What is the current behavior?

The highlighting was changed accidentally in the related PR.

related: #1253

## What is the new behavior?

We revert the highlighting to the previous default i.e.
`ReprHighlighter` which highlights links for example.

## Does this introduce a breaking change?

No.

### Checklist
- [ ] Created tests which fail without the change (if possible)
- [ ] Extended the README / documentation, if necessary
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.

None yet

3 participants