radish-bdd / radish

Behavior Driven Development tooling for Python. The root from red to green.
https://radish-bdd.github.io
MIT License
181 stars 49 forks source link

--no-ansi still outputs colour #359

Closed eerkunt closed 5 years ago

eerkunt commented 5 years ago

Hi,

It looks like even for the cases that --no-ansi is used, [26m is printed in various places ;

  1. On Scenario, Scenario Outline, Feature definitions ; e.g.

    Feature·[26m: Tagging Enforcement·[26m  # /tmp/tmpoatbd3is/tags.feature·[26m 
    In order to keep track of resource ownership 
    As engineers 
    We'll enforce tagging on all resources·[26m 
  2. At the end of each Scenario and Scenario steps ; e.g.

    Scenario·[26m: Ensure all resources have tags·[26m 
        Given I have resource that supports tags defined·[26m 
        Then it must contain tags·[26m 
        And its value must not be null·[26m 
  3. On any assertions that are raised from the steps e.g.

    Failure·[26m: tags property in module.something.aws_iam_role.pipeline_role resource matches with Null/None regex. It is set to None.·[26m 
  4. On Example tables defined within Scenario Outlines ; e.g.

    Examples·[26m: 
        | tag_keys            | pattern             | 
        |·[26m Data Classification |·[26m ^PROTECT - PRIVATE$ |·[26m 
        |·[26m Data Residency      |·[26m ^EU$                |·[26m 
        |·[26m Compliance          |·[26m ^GDPR$              |·[26m 

This is an environment where TERM is not set ( e.g. AWS CodeBuild ) where any colour codes will not work.

timofurrer commented 5 years ago

Thanks for the issue :tada:

Unfortunately, I cannot reproduce the issue. Even if I unset TERM ..

Can you provide a minimal example which is failing for you? What OS and terminal are you using? What version of colorful is installed on your system?

eerkunt commented 5 years ago

I also can not reproduce when I have an interactive shell, even I unset TERM.

We are having this problem where there is no interactive shell and no colour support. In AWS CodeBuild.

Someone else also reported a similar issue while running on Jenkins.

So, as I understand, it must be a non-interactive shell, without Terminal and colour support.

eerkunt commented 5 years ago

colorful version is 0.5.0

fliiiix commented 5 years ago

Is it possible that these characters [26m are part of you feature file?

Because non intereractive non login shell seems to work:

bash -c 'echo $-; shopt login_shell; /home/l33tname/git/other/radish/env/bin/radish --no-ansi -b /home/l33tname/git/other/radish/tests/exploratory/basic/radish /home/l33tname/git/other/radish/tests/exploratory/basic/features/SumNumbers.feature'
hBc
login_shell     off
Feature: Test summing numbers  # /home/l33tname/git/other/radish/tests/exploratory/basic/features/SumNumbers.feature
    In order to test the basic
    features of radish I test
    to sum numbers.
timofurrer commented 5 years ago

@eerkunt I can reproduce your issue. It seems to be a problem with nested colors in colorful.

timofurrer commented 5 years ago

@eerkunt I've just released an alpha release for colorful with a fix: https://pypi.org/project/colorful/0.5.1a1/

Can you please verify if that solved your issue?

eerkunt commented 5 years ago

Checking, thanks a lot!

@fliiiix sorry for missing your request :(

timofurrer commented 5 years ago

So, it worked for you?

eerkunt commented 5 years ago

Just checked, yes it is working for me.

That means, there is no more terminal colouring codes in AWS CodeBuild builds :) 🎉

timofurrer commented 5 years ago

Awesome! Thanks for verifying. I'll release colorful asap. :tada: