• Re: [gentoo-dev] [PATCH] python-utils-r1.eclass: epytest, use NO_COLOR

    From =?UTF-8?Q?Micha=C5=82_G=C3=B3rny?=@21:1/5 to Eli Schwartz on Mon Dec 11 20:30:02 2023
    On Mon, 2023-12-11 at 13:57 -0500, Eli Schwartz wrote:
    On 12/2/23 7:44 AM, Michał Górny wrote:
    Update epytest to respect the modern NO_COLOR variable rather than Portage's old NOCOLOR. Adjust it to correctly check whether it is set
    at all rather than to a specific value, to match the behavior of pytest itself.

    Signed-off-by: Michał Górny <mgorny@gentoo.org>
    ---
    eclass/python-utils-r1.eclass | 11 ++---------
    1 file changed, 2 insertions(+), 9 deletions(-)

    diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass index 394f64a5d139..da9cb820840f 100644
    --- a/eclass/python-utils-r1.eclass
    +++ b/eclass/python-utils-r1.eclass
    @@ -1336,15 +1336,8 @@ epytest() {
    _python_check_EPYTHON
    _python_check_occluded_packages

    - local color
    - case ${NOCOLOR} in
    - true|yes)
    - color=no
    - ;;
    - *)
    - color=yes
    - ;;
    - esac
    + local color=yes
    + [[ ${NO_COLOR} ]] && color=no


    [[ -v NO_COLOR ]]

    This is processed by the pytest code:

    ```
    if "NO_COLOR" in os.environ:
    return False
    ```


    That looks wrong. Per [1]:

    […] NO_COLOR environment variable that, when present and not an empty
    string (regardless of its value), prevents the addition of ANSI color.

    So hey, I'm actually fixing pytest ;-).

    [1] https://no-color.org/

    --
    Best regards,
    Michał Górny


    -----BEGIN PGP SIGNATURE-----

    iQFGBAABCgAwFiEEx2qEUJQJjSjMiybFY5ra4jKeJA4FAmV3YpISHG1nb3JueUBn ZW50b28ub3JnAAoJEGOa2uIyniQOsXQH/jbQ/pLrlOodj6smEeDq5opl3PYpTEdg CSMilFyqaobBIzxfxwJiMg4Qd0VpLoREGoFyebeP80YcwBZ8nNRnk2RZSHCDF4Jz fzUvn0cbJdeIIDDumSS0Hj2z9O7drGUuwDmkrKyvwMIEKLqna8+9pWL0fT0VQGPi 7VKxPCg2wCZvhLgvmvcfz+pPyDwJt8yNKBiqk8jGGhjkIut3/XLJdZjiglm6jRR3 y1Wl/lPnNemE8mrgU2ZhoPxKE5WfF6l+0si+yk7xI81swiX7GssgI8ApwhqF9fae uH4j3O4OjNe18DSWXrJx6Pu6fc7U7gU5I2Z7pWg2fwcbhjRhdtUBvCE=
    =0zGo
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ulrich Mueller@21:1/5 to All on Mon Dec 11 20:40:01 2023
    On Mon, 11 Dec 2023, Eli Schwartz wrote:

    + local color=yes
    + [[ ${NO_COLOR} ]] && color=no

    [[ -v NO_COLOR ]]

    No, this would give the wrong result if NO_COLOR is set to an empty
    value. [[ ${NO_COLOR} ]] or [[ -n ${NO_COLOR} ]] is the correct test:

    "Command-line software which adds ANSI color to its output by default
    should check for a NO_COLOR environment variable that, when present
    and not an empty string (regardless of its value), prevents the
    addition of ANSI color." -- https://no-color.org/

    -----BEGIN PGP SIGNATURE-----

    iQFDBAEBCAAtFiEEtDnZ1O9xIP68rzDbUYgzUIhBXi4FAmV3Yz0PHHVsbUBnZW50 b28ub3JnAAoJEFGIM1CIQV4uClYIAL+5wUHECMVKKOiIpQr5gEDBHroGeBk/0mU7 fzljO87HziNa4WGLW11ZzlGkovoB6x+uqLmjWzNQBxgBpP3p/qLbrsPSivoU+G1h H42WOCdGs8qAx1e1fORM3pzVVlLvgST01e3qHFFjtj4I9q2dHCtlTCNUWfrFUtjH 0IQg4Zb4y2ZbOdniJ9AlzxLZlalUvZtauBvUxvnjnHkOE7XwX0U6fbEzarbDhT3b e8TshIkU1KIeYAG7+SEMULcp860C2CBwRu+3Gni0E/FMXKxe+HDOn/kiquECAons Ctqwq4FWJJ+IX0g2AQTk6qkbDu9fFGckeXkyU+5iSSS+mN2QB7w=
    =tVW2
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ulrich Mueller@21:1/5 to All on Mon Dec 11 21:40:01 2023
    On Mon, 11 Dec 2023, Eli Schwartz wrote:

    "Command-line software which adds ANSI color to its output by default
    should check for a NO_COLOR environment variable that, when present
    and not an empty string (regardless of its value), prevents the
    addition of ANSI color." -- https://no-color.org/

    Again, not according to pytest itself. ;)

    Given the commit message says:

    """
    Adjust it to correctly check whether it is set at all rather than to a specific value, to match the behavior of pytest itself.
    """

    The standard is defined by sno-color.org. If pytest does something
    different then it is a bug.

    Ulrich

    -----BEGIN PGP SIGNATURE-----

    iQFDBAEBCAAtFiEEtDnZ1O9xIP68rzDbUYgzUIhBXi4FAmV3czYPHHVsbUBnZW50 b28ub3JnAAoJEFGIM1CIQV4uBBMIAJWTC5MErLG2wMBBk7v7C85bL3pLhazoDIhf Tfg0I82RkCQnZFlRrbPxSj/KZ3B5XRbXJ2P8weLR7l+wQmZhWv308NBHCG3ERqBo 2X7hln2lKowYmrJGwxwvHAnKTY5QiokAOFJ9LQmp9Yfi7WQaTjiver/ok163trPb UTc/qB/uegsp+yqwI/RM0uZClZQdCB+D3UCh1ndu4ipaDNgp9jLtDb+jny3ZdwNG tW2A9SmmPuntKKld66grDP4gLmA1oycF7/ZoZhwuWngmlQe1joNJKvGnUmMSuMGp V4KXYr3nlZj933ZxWB2mUD5+kJZuoDdrRUehZyQolcYGSILrxJg=
    =MLzs
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Toralf_F=C3=B6rster?=@21:1/5 to All on Mon Dec 11 22:20:02 2023
    This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------------s5CPUN73iJ0GXODqh9xmq4A1
    Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: base64

    T24gMTIvMTEvMjMgMjE6MzgsIFVscmljaCBNdWVsbGVyIHdyb3RlOg0KDQo+IFRoZSBzdGFu ZGFyZCBpcyBkZWZpbmVkIGJ5IHNuby1jb2xvci5vcmcuDQoNCmh0dHA6Ly9uby1jb2xvci5v cmcNCg0KLS0gDQpUb3JhbGYNClBHUCAyMzIxN0RBNyA5Qjg4OEY0NQ0KDQo=

    --------------s5CPUN73iJ0GXODqh9xmq4A1--

    -----BEGIN PGP SIGNATURE-----

    wsF5BAABCAAjFiEE4Aq096H1MGPqWQN3byNRLEwPvR0FAmV3ev4FAwAAAAAACgkQbyNRLEwPvR0d ihAAhDVlNnq2CgDjBLQG2LSIVNoevyQWJZRkldGNfpwQA0F5XCV0hsn5q3Ih3f6k48vcfY+TgmTJ NwU47ICNUtlx5s+/UDC1DXSU59LwNAT5/608rvHxm9C/2Sf+R/AXze35oUFbNpptuabntFLElQAg L02ClJ2+5QoC7IOkmvQKxRh+3dxGHvb8DBJ4qtPqdWuZQCaotjGtPmwhG1xPTW0S3tkkTzoRNQjS v7jcSemyscu+FOLtUdVaWog8PMkj6AJpmQYmmaORRf1RAg974xiBBgzoIqO8o5CkSahjo5Myps9Y FCglGQ2Qe2oKugAb+Ps7rjsLVheKAzkbIpIRPBIuDCqiRH+6fPyD6aK5XD4m1fMQSUXvKiGkH+VT jphiAb8M50AKElGBgaSc1GHRZTpRGIEXKE/yVDl7usDHbentDeyMssJr/MEGakyzXVUX0UaPonY8 qd05/rxa/W8lsabXzP/vV/vrhJBRkgHonyo7dn2y+WBIGADXfZliRnbgZwnJySeIV+4dLpNYRIM5 G18psQbd3Khvt0akLItecEczv1B8mM9HKTKEkrJDHqPQk2Ds0Hdj1QYNukej1+R3yvNpJnOUP/2M u0ZYTNpH/i5I4vTR4rUsUQpytabFbYXHItHal2UfjlxROK9SpFn3hkeZeyus9NnxBaRT+FLdrFJU jxU=
    =5LVm
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)