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

fix: add support for no colors mode #359

Merged
merged 5 commits into from
Sep 20, 2020
Merged

fix: add support for no colors mode #359

merged 5 commits into from
Sep 20, 2020

Conversation

iamogbz
Copy link
Collaborator

@iamogbz iamogbz commented Sep 19, 2020

Description

Adds support no colors mode with environment variables NO_COLOR, ANSI_COLORS_DISABLED or pytest option.

Related Issues

Checklist

  • This PR has sufficient documentation.
  • This PR has sufficient test coverage.
  • This PR title satisfies semantic convention.

Additional Comments

  • pytest supports by default NO_COLOR

@codecov
Copy link

codecov bot commented Sep 19, 2020

Codecov Report

Merging #359 into master will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master      #359   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           19        19           
  Lines          957       992   +35     
=========================================
+ Hits           957       992   +35     

@iamogbz iamogbz requested a review from noahnu September 19, 2020 18:04
| `--snapshot-update` | Snapshots will be updated to match assertions and unused snapshots will be deleted. | `False` |
| `--snapshot-warn-unused` | Prints a warning on unused snapshots rather than fail the test suite. | `False` |
| `--snapshot-default-extension` | Use to change the default snapshot extension class. | `syrupy.extensions.amber.AmberSnapshotExtension` |
| `--snapshot-no-colors` | Disable test results output highlighting. Equivalent to setting the environment variables `ANSI_COLORS_DISABLED` or `NO_COLOR` | Disabled by default if not in terminal. |
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does pytest also natively support ANSI_COLORS_DISABLED?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

pytest supports by default NO_COLOR

So added both

Copy link
Collaborator

@noahnu noahnu left a comment

Choose a reason for hiding this comment

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

LGTM



def _is_color_disabled() -> bool:
return any(map(get_env_value, DISABLE_COLOR_ENV_VARS))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm fine with this (and actually prefer it) but I thought we had a lint rule around preferring comprehension over map/reduce etc

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think there's a lint rule around it, just a general case by case basis imo

@iamogbz iamogbz merged commit ec39b80 into master Sep 20, 2020
@iamogbz iamogbz deleted the no-color-mode branch September 20, 2020 00:25
syrupy-bot pushed a commit that referenced this pull request Sep 20, 2020
## [0.7.2](v0.7.1...v0.7.2) (2020-09-20)

### Bug Fixes

* add support for no colors mode ([#359](#359)) ([ec39b80](ec39b80))
@syrupy-bot
Copy link
Contributor

🎉 This PR is included in version 0.7.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

A "no formatting" mode for CI runs which don't support text formatting
3 participants