pytest-sugar icon indicating copy to clipboard operation
pytest-sugar copied to clipboard

pytest-sugar not work in github actions

Open liukangcc opened this issue 4 years ago • 1 comments

when i use pytest-sugar in github actions docker, it seems look not work. The docker image install pytest already.

Install log

[sdk_check.py 25 INFO] Collecting pytest-sugar
  Downloading pytest-sugar-0.9.4.tar.gz (12 kB)
Collecting pytest-html
  Downloading pytest_html-2.1.1-py2.py3-none-any.whl (16 kB)
Requirement already satisfied: pytest>=2.9 in /usr/local/lib/python3.6/site-packages (from pytest-sugar) (6.1.1)
Collecting termcolor>=1.1.0
  Downloading termcolor-1.1.0.tar.gz (3.9 kB)
Requirement already satisfied: packaging>=14.1 in /usr/local/lib/python3.6/site-packages (from pytest-sugar) (20.4)
Collecting pytest-metadata
  Downloading pytest_metadata-1.10.0-py2.py3-none-any.whl (9.9 kB)
Requirement already satisfied: importlib-metadata>=0.12; python_version < "3.8" in /usr/local/lib/python3.6/site-packages (from pytest>=2.9->pytest-sugar) (2.0.0)
Requirement already satisfied: attrs>=17.4.0 in /usr/local/lib/python3.6/site-packages (from pytest>=2.9->pytest-sugar) (20.2.0)
Requirement already satisfied: py>=1.8.2 in /usr/local/lib/python3.6/site-packages (from pytest>=2.9->pytest-sugar) (1.9.0)
Requirement already satisfied: toml in /usr/local/lib/python3.6/site-packages (from pytest>=2.9->pytest-sugar) (0.10.1)
Requirement already satisfied: iniconfig in /usr/local/lib/python3.6/site-packages (from pytest>=2.9->pytest-sugar) (1.1.1)
Requirement already satisfied: pluggy<1.0,>=0.12 in /usr/local/lib/python3.6/site-packages (from pytest>=2.9->pytest-sugar) (0.13.1)
Requirement already satisfied: six in /usr/local/lib/python3.6/site-packages (from packaging>=14.1->pytest-sugar) (1.15.0)
Requirement already satisfied: pyparsing>=2.0.2 in /usr/local/lib/python3.6/site-packages (from packaging>=14.1->pytest-sugar) (2.4.7)
Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.6/site-packages (from importlib-metadata>=0.12; python_version < "3.8"->pytest>=2.9->pytest-sugar) (3.3.1)
Building wheels for collected packages: pytest-sugar, termcolor
  Building wheel for pytest-sugar (setup.py): started
  Building wheel for pytest-sugar (setup.py): finished with status 'done'
  Created wheel for pytest-sugar: filename=pytest_sugar-0.9.4-py2.py3-none-any.whl size=8972 sha256=b5d7d3f716042e1c34c92417e7905d455cd4dfa28f381eb1fb3d7801934a00c9
  Stored in directory: /root/.cache/pip/wheels/21/2b/b9/a7669a62d8d18d69ae266cdb07760f50db857e4032d1e37216
  Building wheel for termcolor (setup.py): started
  Building wheel for termcolor (setup.py): finished with status 'done'
  Created wheel for termcolor: filename=termcolor-1.1.0-py3-none-any.whl size=4830 sha256=d049706bfd26e0d7436d00b66b15fa5e2560c892bb68d6ca92736992166e461c
  Stored in directory: /root/.cache/pip/wheels/93/2a/eb/e58dbcbc963549ee4f065ff80a59f274cc7210b6eab962acdc
Successfully built pytest-sugar termcolor
Installing collected packages: termcolor, pytest-sugar, pytest-metadata, pytest-html
Successfully installed pytest-html-2.1.1 pytest-metadata-1.10.0 pytest-sugar-0.9.4 termcolor-1.1.0

Command used to run pytest

pytest.main(["sdk_test_case.py", '--html=report.html', '--self-contained-html'])

Test file

def test_example():
    assert 1==1

Output

============================= test session starts ==============================
platform linux -- Python 3.6.12, pytest-6.1.1, py-1.9.0, pluggy-0.13.1
rootdir: /tools/sdk_check
plugins: metadata-1.10.0, sugar-0.9.4, html-2.1.1
collected 1 item

sdk_test_case.py .                                                       [100%]

- generated html file: file:///tools/sdk_check/report.html -
============================== 1 passed in 13.31s ==============================

liukangcc avatar Nov 10 '20 08:11 liukangcc

@thread-liu you can use --force-sugar to enable sugar inside a container, by default the check sys.stdout.isatty() made here[¹] will return False, so pytest-sugar will be disabled.

[¹] https://github.com/Teemu/pytest-sugar/blob/master/pytest_sugar.py#L159

eriol avatar Feb 25 '21 16:02 eriol