Hello community, here is the log from the commit of package python-pytest-subtests for openSUSE:Factory checked in at 2020-02-20 14:57:49 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-pytest-subtests (Old) and /work/SRC/openSUSE:Factory/.python-pytest-subtests.new.26092 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pytest-subtests" Thu Feb 20 14:57:49 2020 rev:2 rq:777568 version:0.3.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-pytest-subtests/python-pytest-subtests.changes 2019-08-29 17:25:57.379283130 +0200 +++ /work/SRC/openSUSE:Factory/.python-pytest-subtests.new.26092/python-pytest-subtests.changes 2020-02-20 14:57:53.870584444 +0100 @@ -1,0 +2,6 @@ +Thu Feb 20 07:12:11 UTC 2020 - Tomáš Chvátal <tchva...@suse.com> + +- Update to 0.3.0: + * subtests now correctly captures and displays stdout/stderr (#18). + +------------------------------------------------------------------- Old: ---- pytest-subtests-0.2.1.tar.gz New: ---- pytest-subtests-0.3.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-pytest-subtests.spec ++++++ --- /var/tmp/diff_new_pack.hMDAjm/_old 2020-02-20 14:57:54.758586186 +0100 +++ /var/tmp/diff_new_pack.hMDAjm/_new 2020-02-20 14:57:54.762586195 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-pytest-subtests # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,29 +12,28 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 Name: python-pytest-subtests -Version: 0.2.1 +Version: 0.3.0 Release: 0 -License: MIT Summary: Python unittest subTest() support and subtests fixture -Url: https://github.com/pytest-dev/pytest-subtests -Group: Development/Languages/Python +License: MIT +URL: https://github.com/pytest-dev/pytest-subtests Source: https://files.pythonhosted.org/packages/source/p/pytest-subtests/pytest-subtests-%{version}.tar.gz -BuildRequires: python-rpm-macros BuildRequires: %{python_module setuptools >= 40.0} BuildRequires: %{python_module setuptools_scm} -# SECTION test requirements -BuildRequires: %{python_module pytest >= 4.4.0} -# /SECTION BuildRequires: fdupes +BuildRequires: python-rpm-macros Requires: python-pytest >= 4.4.0 BuildArch: noarch - +# SECTION test requirements +BuildRequires: %{python_module pytest >= 4.4.0} +# /SECTION %python_subpackages %description ++++++ pytest-subtests-0.2.1.tar.gz -> pytest-subtests-0.3.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-subtests-0.2.1/.github/workflows/main.yml new/pytest-subtests-0.3.0/.github/workflows/main.yml --- old/pytest-subtests-0.2.1/.github/workflows/main.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-subtests-0.3.0/.github/workflows/main.yml 2020-01-23 01:01:31.000000000 +0100 @@ -0,0 +1,105 @@ +name: build + +on: [push, pull_request] + +jobs: + build: + + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + name: [ + "windows-py35", + "windows-py36", + "windows-py37", + "windows-py38", + + "ubuntu-py35", + "ubuntu-py36", + "ubuntu-py37", + "ubuntu-py38", + + "linting", + ] + + include: + - name: "windows-py35" + python: "3.5" + os: windows-latest + tox_env: "py35" + - name: "windows-py36" + python: "3.6" + os: windows-latest + tox_env: "py36" + - name: "windows-py37" + python: "3.7" + os: windows-latest + tox_env: "py37" + - name: "windows-py38" + python: "3.8" + os: windows-latest + tox_env: "py38" + + - name: "ubuntu-py35" + python: "3.5" + os: ubuntu-latest + tox_env: "py35" + - name: "ubuntu-py36" + python: "3.6" + os: ubuntu-latest + tox_env: "py36" + - name: "ubuntu-py37" + python: "3.7" + os: ubuntu-latest + tox_env: "py37" + - name: "ubuntu-py38" + python: "3.8" + os: ubuntu-latest + tox_env: "py38" + + - name: "linting" + python: "3.7" + os: ubuntu-latest + tox_env: "linting" + + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python }} + - name: Install tox + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade tox setuptools + - name: Test + run: | + tox -e ${{ matrix.tox_env }} + + deploy: + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') + + runs-on: ubuntu-latest + + needs: [build] + + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: "3.7" + - name: Install wheel + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade wheel setuptools + - name: Build package + run: | + python setup.py sdist bdist_wheel + - name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.pypi_token }} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-subtests-0.2.1/.pre-commit-config.yaml new/pytest-subtests-0.3.0/.pre-commit-config.yaml --- old/pytest-subtests-0.2.1/.pre-commit-config.yaml 2019-04-05 00:08:07.000000000 +0200 +++ new/pytest-subtests-0.3.0/.pre-commit-config.yaml 2020-01-23 01:01:31.000000000 +0100 @@ -1,48 +1,25 @@ repos: - repo: https://github.com/ambv/black - rev: 18.9b0 + rev: 19.10b0 hooks: - id: black args: [--safe, --quiet] - language_version: python3 -- repo: https://github.com/asottile/blacken-docs - rev: v0.3.0 - hooks: - - id: blacken-docs - additional_dependencies: [black==18.9b0] - language_version: python3 - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.1.0 + rev: v2.2.3 hooks: - id: trailing-whitespace - id: end-of-file-fixer - id: check-yaml - id: debug-statements - language_version: python3 -- repo: https://gitlab.com/pycqa/flake8 - rev: 3.7.0 - hooks: - - id: flake8 - language_version: python3 - repo: https://github.com/asottile/reorder_python_imports - rev: v1.3.5 + rev: v1.4.0 hooks: - id: reorder-python-imports - args: ['--application-directories=.:src'] -- repo: https://github.com/asottile/pyupgrade - rev: v1.11.1 - hooks: - - id: pyupgrade - args: [--keep-percent-format] -- repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.2.0 - hooks: - - id: rst-backticks - repo: local hooks: - id: rst name: rst entry: rst-lint --encoding utf-8 - files: ^(CHANGELOG.rst|HOWTORELEASE.rst|README.rst|changelog/.*)$ + files: ^(CHANGELOG.rst|HOWTORELEASE.rst|README.rst)$ language: python additional_dependencies: [pygments, restructuredtext_lint] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-subtests-0.2.1/.travis.yml new/pytest-subtests-0.3.0/.travis.yml --- old/pytest-subtests-0.2.1/.travis.yml 2019-04-05 00:08:07.000000000 +0200 +++ new/pytest-subtests-0.3.0/.travis.yml 1970-01-01 01:00:00.000000000 +0100 @@ -1,48 +0,0 @@ -sudo: false -language: python -dist: xenial - -stages: -- test -- name: deploy - if: repo = pytest-dev/pytest-subtests AND tag IS present - -jobs: - include: - - python: '3.4' - env: TOXENV=py34 - - python: '3.5' - env: TOXENV=py35 - - python: '3.6' - env: TOXENV=py36 - - python: '3.7' - env: TOXENV=py37 - - python: 'pypy3.5-6.0' - env: TOXENV=pypy3 - - python: '3.7' - env: TOXENV=linting - - stage: deploy - python: '3.7' - install: pip install -U setuptools setuptools_scm - script: skip - deploy: - provider: pypi - user: nicoddemus - distributions: sdist bdist_wheel - skip_upload_docs: true - password: - secure: CJBATZL5nzJNzjrvTRnMeJOKv1yFwSMp0jZ+GX4bDkq3+4H8EW08Hy/2DpCusK4fdC0CHT6CmO/YsLV9BuFdD4ozvBDhcuJqSLbPlt/R152xiOppvwZ9b2sMN6tmA8lIQB+nmwfmCIhI9jb9p882OZjz26C5ekD+RqM4JWpmh3KZqNLPsTR3xWOdL3WTET9HKNiWrwZtvJJwBKwF3ITE58SvHXMHfjCaWOk9hY2uK0+oUSev+Ww8L92jQLq73KLoSsEFvwKEKbssstcQmMk99jICvKaiOsQT0SarMzITWapQh9Thu2iRrfZVFr4AG3bywReeoM5zaXuwXOdEN1e+Lk2DRv0W/LQCDCWJiEBvDZXeIBT8B7aV8pHGKAw0P6xbkHOt2IE8tPZYcccqi6kV4b/Wz9Lqk4ilk/V4TYGAbss9wO2WORWAm1GQrg5zSAeivnmlB4sybwF6RGxJwC5Pr9KWYFPmKGQXdVsBmbiB4RpAsQfAdYIEWc9Kfn7aEQX6dthFEy9R6oWSlCY1aG0M4lLt/zOqKxr6pfdOqNwxgkMSeZkpmCU0jS5FPSJ8DuboAOdCU62MCV+6TM/CCFsrvYWxKgS2djO+9UGXiJjrWpWux2DlP6S8AuyADorExpZc+12VMLr6/+dqLRmo96yPcH6KH1owu2l/0ErAND/UF3A= - on: - tags: true - repo: pytest-dev/pytest-subtests - -install: - - pip install --upgrade pip - - pip install --upgrade setuptools tox - -script: - - tox - -cache: - directories: - - $HOME/.cache/pre-commit diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-subtests-0.2.1/CHANGELOG.rst new/pytest-subtests-0.3.0/CHANGELOG.rst --- old/pytest-subtests-0.2.1/CHANGELOG.rst 2019-04-05 00:08:07.000000000 +0200 +++ new/pytest-subtests-0.3.0/CHANGELOG.rst 2020-01-23 01:01:31.000000000 +0100 @@ -1,6 +1,14 @@ CHANGELOG ========= +0.3.0 (2020-01-22) +------------------ + +* Dropped support for Python 3.4. +* ``subtests`` now correctly captures and displays stdout/stderr (`#18`_). + +.. _#18: https://github.com/pytest-dev/pytest-subtests/issues/18 + 0.2.1 (2019-04-04) ------------------ @@ -11,7 +19,7 @@ 0.2.0 (2019-04-03) ------------------ -* Sub tests are correctly reported with ``pytest-xdist>=1.28``. +* Subtests are correctly reported with ``pytest-xdist>=1.28``. 0.1.0 (2019-04-01) ------------------ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-subtests-0.2.1/PKG-INFO new/pytest-subtests-0.3.0/PKG-INFO --- old/pytest-subtests-0.2.1/PKG-INFO 2019-04-05 00:08:31.000000000 +0200 +++ new/pytest-subtests-0.3.0/PKG-INFO 2020-01-23 01:01:44.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.2 Name: pytest-subtests -Version: 0.2.1 +Version: 0.3.0 Summary: unittest subTest() support and subtests fixture Home-page: https://github.com/pytest-dev/pytest-subtests Author: Bruno Oliveira @@ -25,13 +25,8 @@ :target: https://pypi.org/project/pytest-subtests :alt: Python versions - .. image:: https://travis-ci.com/pytest-dev/pytest-subtests.svg?branch=master - :target: https://travis-ci.com/pytest-dev/pytest-subtests - :alt: See Build Status on Travis CI - - .. image:: https://pytest-dev.visualstudio.com/pytest-subtests/_apis/build/status/pytest-dev.pytest-subtests?branchName=master - :target: https://dev.azure.com/pytest-dev/pytest-subtests - :alt: See Build Status on Azure + .. image:: https://github.com/pytest-dev/pytest-subtests/workflows/build/badge.svg + :target: https://github.com/pytest-dev/pytest-subtests/actions .. image:: https://img.shields.io/badge/code%20style-black-000000.svg :target: https://github.com/ambv/black @@ -52,7 +47,7 @@ Requirements ------------ - * ``Python`` >= 3.4. + * ``Python`` >= 3.5. * ``pytest`` >= 4.4. Installation @@ -205,12 +200,11 @@ Classifier: Topic :: Software Development :: Testing Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 +Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: Implementation :: CPython -Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Operating System :: OS Independent Classifier: License :: OSI Approved :: MIT License -Requires-Python: >=3.4 +Requires-Python: >=3.5 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-subtests-0.2.1/README.rst new/pytest-subtests-0.3.0/README.rst --- old/pytest-subtests-0.2.1/README.rst 2019-04-05 00:08:07.000000000 +0200 +++ new/pytest-subtests-0.3.0/README.rst 2020-01-23 01:01:31.000000000 +0100 @@ -15,13 +15,8 @@ :target: https://pypi.org/project/pytest-subtests :alt: Python versions -.. image:: https://travis-ci.com/pytest-dev/pytest-subtests.svg?branch=master - :target: https://travis-ci.com/pytest-dev/pytest-subtests - :alt: See Build Status on Travis CI - -.. image:: https://pytest-dev.visualstudio.com/pytest-subtests/_apis/build/status/pytest-dev.pytest-subtests?branchName=master - :target: https://dev.azure.com/pytest-dev/pytest-subtests - :alt: See Build Status on Azure +.. image:: https://github.com/pytest-dev/pytest-subtests/workflows/build/badge.svg + :target: https://github.com/pytest-dev/pytest-subtests/actions .. image:: https://img.shields.io/badge/code%20style-black-000000.svg :target: https://github.com/ambv/black @@ -42,7 +37,7 @@ Requirements ------------ -* ``Python`` >= 3.4. +* ``Python`` >= 3.5. * ``pytest`` >= 4.4. Installation diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-subtests-0.2.1/azure-pipelines.yml new/pytest-subtests-0.3.0/azure-pipelines.yml --- old/pytest-subtests-0.2.1/azure-pipelines.yml 2019-04-05 00:08:07.000000000 +0200 +++ new/pytest-subtests-0.3.0/azure-pipelines.yml 1970-01-01 01:00:00.000000000 +0100 @@ -1,62 +0,0 @@ -variables: - PYTEST_ADDOPTS: "--junitxml=build/test-results/$(tox.env).xml" - python.exe: "python" - -jobs: - -- job: 'Test' - pool: - vmImage: "vs2017-win2016" - strategy: - matrix: - # pypy3 is failing because of: https://bitbucket.org/pypy/pypy/issues/2928/invoking-pypy3-v600-by-tox-on-windows-10 -# pypy: -# python.version: 'pypy3' -# tox.env: 'pypy3' -# python.exe: 'pypy3' - py34: - python.version: '3.4' - tox.env: 'py34' - py35: - python.version: '3.5' - tox.env: 'py35' - py36: - python.version: '3.6' - tox.env: 'py36' - py37: - python.version: '3.7' - tox.env: 'py37' - maxParallel: 10 - - steps: - - task: UsePythonVersion@0 - condition: not(startsWith(variables['python.exe'], 'pypy')) - inputs: - versionSpec: '$(python.version)' - architecture: 'x64' - - - script: choco install pypy3 - condition: eq(variables['python.exe'], 'pypy3') - displayName: 'Install pypy3' - - - task: PowerShell@2 - inputs: - targetType: 'inline' - script: | - Invoke-WebRequest -Uri "https://bootstrap.pypa.io/get-pip.py" -OutFile "get-pip.py" - $(python.exe) get-pip.py - condition: startsWith(variables['python.exe'], 'pypy') - displayName: 'Install pip' - - - script: $(python.exe) -m pip install --upgrade pip && $(python.exe) -m pip install tox - displayName: 'Install tox' - - - script: | - $(python.exe) -m tox -e $(tox.env) - displayName: 'Run tests' - - - task: PublishTestResults@2 - inputs: - testResultsFiles: 'build/test-results/$(tox.env).xml' - testRunTitle: '$(tox.env)' - condition: succeededOrFailed() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-subtests-0.2.1/pytest_subtests.egg-info/PKG-INFO new/pytest-subtests-0.3.0/pytest_subtests.egg-info/PKG-INFO --- old/pytest-subtests-0.2.1/pytest_subtests.egg-info/PKG-INFO 2019-04-05 00:08:30.000000000 +0200 +++ new/pytest-subtests-0.3.0/pytest_subtests.egg-info/PKG-INFO 2020-01-23 01:01:42.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.2 Name: pytest-subtests -Version: 0.2.1 +Version: 0.3.0 Summary: unittest subTest() support and subtests fixture Home-page: https://github.com/pytest-dev/pytest-subtests Author: Bruno Oliveira @@ -25,13 +25,8 @@ :target: https://pypi.org/project/pytest-subtests :alt: Python versions - .. image:: https://travis-ci.com/pytest-dev/pytest-subtests.svg?branch=master - :target: https://travis-ci.com/pytest-dev/pytest-subtests - :alt: See Build Status on Travis CI - - .. image:: https://pytest-dev.visualstudio.com/pytest-subtests/_apis/build/status/pytest-dev.pytest-subtests?branchName=master - :target: https://dev.azure.com/pytest-dev/pytest-subtests - :alt: See Build Status on Azure + .. image:: https://github.com/pytest-dev/pytest-subtests/workflows/build/badge.svg + :target: https://github.com/pytest-dev/pytest-subtests/actions .. image:: https://img.shields.io/badge/code%20style-black-000000.svg :target: https://github.com/ambv/black @@ -52,7 +47,7 @@ Requirements ------------ - * ``Python`` >= 3.4. + * ``Python`` >= 3.5. * ``pytest`` >= 4.4. Installation @@ -205,12 +200,11 @@ Classifier: Topic :: Software Development :: Testing Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 +Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: Implementation :: CPython -Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Operating System :: OS Independent Classifier: License :: OSI Approved :: MIT License -Requires-Python: >=3.4 +Requires-Python: >=3.5 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-subtests-0.2.1/pytest_subtests.egg-info/SOURCES.txt new/pytest-subtests-0.3.0/pytest_subtests.egg-info/SOURCES.txt --- old/pytest-subtests-0.2.1/pytest_subtests.egg-info/SOURCES.txt 2019-04-05 00:08:31.000000000 +0200 +++ new/pytest-subtests-0.3.0/pytest_subtests.egg-info/SOURCES.txt 2020-01-23 01:01:44.000000000 +0100 @@ -1,14 +1,13 @@ .gitignore .pre-commit-config.yaml -.travis.yml CHANGELOG.rst HOWTORELEASE.rst LICENSE README.rst -azure-pipelines.yml pytest_subtests.py setup.py tox.ini +.github/workflows/main.yml pytest_subtests.egg-info/PKG-INFO pytest_subtests.egg-info/SOURCES.txt pytest_subtests.egg-info/dependency_links.txt diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-subtests-0.2.1/pytest_subtests.py new/pytest-subtests-0.3.0/pytest_subtests.py --- old/pytest-subtests-0.2.1/pytest_subtests.py 2019-04-05 00:08:07.000000000 +0200 +++ new/pytest-subtests-0.3.0/pytest_subtests.py 2020-01-23 01:01:31.000000000 +0100 @@ -1,10 +1,13 @@ import sys from contextlib import contextmanager -from time import time +from time import monotonic import attr import pytest from _pytest._code import ExceptionInfo +from _pytest.capture import CaptureFixture +from _pytest.capture import FDCapture +from _pytest.capture import SysCapture from _pytest.outcomes import OutcomeException from _pytest.reports import TestReport from _pytest.runner import CallInfo @@ -96,31 +99,81 @@ suspend_capture_ctx = capmam.global_and_fixture_disabled else: suspend_capture_ctx = nullcontext - yield SubTests(request.node.ihook, request.node, suspend_capture_ctx) + yield SubTests(request.node.ihook, suspend_capture_ctx, request) @attr.s class SubTests(object): ihook = attr.ib() - item = attr.ib() suspend_capture_ctx = attr.ib() + request = attr.ib() + + @property + def item(self): + return self.request.node + + @contextmanager + def _capturing_output(self): + option = self.request.config.getoption("capture", None) + + # capsys or capfd are active, subtest should not capture + capture_fixture_active = hasattr(self.request.node, "_capture_fixture") + + if option == "sys" and not capture_fixture_active: + fixture = CaptureFixture(SysCapture, self.request) + elif option == "fd" and not capture_fixture_active: + fixture = CaptureFixture(FDCapture, self.request) + else: + fixture = None + + if fixture is not None: + fixture._start() + + captured = Captured() + try: + yield captured + finally: + if fixture is not None: + out, err = fixture.readouterr() + fixture.close() + captured.out = out + captured.err = err @contextmanager def test(self, msg=None, **kwargs): - start = time() + start = monotonic() exc_info = None - try: - yield - except (Exception, OutcomeException): - exc_info = ExceptionInfo.from_current() - stop = time() + + with self._capturing_output() as captured: + try: + yield + except (Exception, OutcomeException): + exc_info = ExceptionInfo.from_current() + + stop = monotonic() + call_info = CallInfo(None, exc_info, start, stop, when="call") sub_report = SubTestReport.from_item_and_call(item=self.item, call=call_info) sub_report.context = SubTestContext(msg, kwargs.copy()) + + captured.update_report(sub_report) + with self.suspend_capture_ctx(): self.ihook.pytest_runtest_logreport(report=sub_report) +@attr.s +class Captured: + out = attr.ib(default="", type=str) + err = attr.ib(default="", type=str) + + def update_report(self, report): + if self.out: + report.sections.append(("Captured stdout call", self.out)) + if self.err: + report.sections.append(("Captured stderr call", self.err)) + + def pytest_report_to_serializable(report): if isinstance(report, SubTestReport): return report._to_json() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-subtests-0.2.1/setup.py new/pytest-subtests-0.3.0/setup.py --- old/pytest-subtests-0.2.1/setup.py 2019-04-05 00:08:07.000000000 +0200 +++ new/pytest-subtests-0.3.0/setup.py 2020-01-23 01:01:31.000000000 +0100 @@ -11,7 +11,6 @@ setup( name="pytest-subtests", - version="0.1.0", author="Bruno Oliveira", author_email="nicodde...@gmail.com", maintainer="Bruno Oliveira", @@ -23,7 +22,7 @@ py_modules=["pytest_subtests"], use_scm_version=True, setup_requires=["setuptools-scm", "setuptools>=40.0"], - python_requires=">=3.4", + python_requires=">=3.5", install_requires=["pytest>=4.4.0"], classifiers=[ "Development Status :: 4 - Beta", @@ -32,12 +31,11 @@ "Topic :: Software Development :: Testing", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy", "Operating System :: OS Independent", "License :: OSI Approved :: MIT License", ], diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-subtests-0.2.1/tests/test_subtests.py new/pytest-subtests-0.3.0/tests/test_subtests.py --- old/pytest-subtests-0.2.1/tests/test_subtests.py 2019-04-05 00:08:07.000000000 +0200 +++ new/pytest-subtests-0.3.0/tests/test_subtests.py 2020-01-23 01:01:31.000000000 +0100 @@ -219,3 +219,91 @@ result.stdout.fnmatch_lines( ["collected 1 item", "* 3 skipped, 1 passed in *"] ) + + +class TestCapture: + def create_file(self, testdir): + testdir.makepyfile( + """ + import sys + def test(subtests): + print() + print('start test') + + with subtests.test(i='A'): + print("hello stdout A") + print("hello stderr A", file=sys.stderr) + assert 0 + + with subtests.test(i='B'): + print("hello stdout B") + print("hello stderr B", file=sys.stderr) + assert 0 + + print('end test') + assert 0 + """ + ) + + def test_capturing(self, testdir): + self.create_file(testdir) + result = testdir.runpytest() + result.stdout.fnmatch_lines( + [ + "*__ test (i='A') __*", + "*Captured stdout call*", + "hello stdout A", + "*Captured stderr call*", + "hello stderr A", + "*__ test (i='B') __*", + "*Captured stdout call*", + "hello stdout B", + "*Captured stderr call*", + "hello stderr B", + "*__ test __*", + "*Captured stdout call*", + "start test", + "end test", + ] + ) + + def test_no_capture(self, testdir): + self.create_file(testdir) + result = testdir.runpytest("-s") + result.stdout.fnmatch_lines( + [ + "start test", + "hello stdout A", + "Fhello stdout B", + "Fend test", + "*__ test (i='A') __*", + "*__ test (i='B') __*", + "*__ test __*", + ] + ) + result.stderr.fnmatch_lines(["hello stderr A", "hello stderr B"]) + + @pytest.mark.parametrize("fixture", ["capsys", "capfd"]) + def test_capture_with_fixture(self, testdir, fixture): + testdir.makepyfile( + r""" + import sys + + def test(subtests, {fixture}): + print('start test') + + with subtests.test(i='A'): + print("hello stdout A") + print("hello stderr A", file=sys.stderr) + + out, err = {fixture}.readouterr() + assert out == 'start test\nhello stdout A\n' + assert err == 'hello stderr A\n' + """.format( + fixture=fixture + ) + ) + result = testdir.runpytest() + result.stdout.fnmatch_lines( + ["*1 passed*",] + )