Skip to content

Commit

Permalink
Initial COmmit For Release 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ssrikanta committed Aug 19, 2016
0 parents commit 08b400c
Show file tree
Hide file tree
Showing 10 changed files with 318 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Release Notes
-------------

**1.0.0 (2016-08-18)**

* Intitial Plugin Release

3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include README.rst
include tox.ini
include test_progress_report.py
34 changes: 34 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
pytest-excel
================


pytest-progress is a plugin for `py.test <http://pytest.org>`_ that allows to
print the test progress like number of tests Passed , Failed, Skipped and also
instant test failure messages.


Requirements
------------

You will need the following prerequisites in order to use pytest-progress:

- Python 2.7, 3.4 or 3.5
- pytest 2.9.0 or newer



Installation
------------

To install pytest-progress::

$ pip install pytest-progress

Then run your tests with::

$ py.test --show-progress

If you would like more detailed output (one test per line), then you may use the verbose option::

$ py.test --verbose

1 change: 1 addition & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
collect_ignore = ['setup.py', 'test_progress_report.py']
168 changes: 168 additions & 0 deletions pytest_progress.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@

import pytest
from _pytest.terminal import TerminalReporter


def pytest_collection_modifyitems(session, config, items):
terminal_reporter = config.pluginmanager.getplugin('terminalreporter')
if terminal_reporter:
terminal_reporter.tests_count = len(items)


try:
import xdist
except ImportError:
pass
else:
from distutils.version import LooseVersion
xdist_version = LooseVersion(xdist.__version__)
if xdist_version >= LooseVersion("1.14"):
def pytest_xdist_node_collection_finished(node, ids):
terminal_reporter = node.config.pluginmanager.getplugin('terminalreporter')
if terminal_reporter:
terminal_reporter.tests_count = len(ids)



def pytest_addoption(parser):
group = parser.getgroup("terminal reporting")
group.addoption('--showprogress', '--show-progress',
action="count",
default=0,
dest="progress",
help="Prints test progress on the terminal.")



@pytest.mark.trylast
def pytest_configure(config):
progress = config.option.progress

if progress and not getattr(config, 'slaveinput', None):
standard_reporter = config.pluginmanager.getplugin('terminalreporter')
instaprogress_reporter = ProgressTerminalReporter(standard_reporter)

config.pluginmanager.unregister(standard_reporter)
config.pluginmanager.register(instaprogress_reporter, 'terminalreporter')


class ProgressTerminalReporter(TerminalReporter):


def __init__(self, reporter):
TerminalReporter.__init__(self, reporter.config)
self._tw = reporter._tw
self.tests_count = 0
self.tests_taken = 0
self.pass_count = 0
self.fail_count = 0
self.skip_count = 0
self.xpass_count = 0
self.xfail_count = 0
self.error_count = 0


def append_pass(self):
self.pass_count = self.pass_count + 1
self.tests_taken = self.tests_taken + 1


def append_failure(self, report):

if hasattr(report, "wasxfail"):
self.xpass_count = self.xpass_count + 1
self.tests_taken = self.tests_taken + 1

else:
self.fail_count = self.fail_count + 1
self.tests_taken = self.tests_taken + 1


def append_error(self):

self.error_count = self.error_count + 1
self.tests_taken = self.tests_taken + 1


def append_skipped(self, report):

if hasattr(report, "wasxfail"):
self.xfail_count = self.xfail_count + 1
self.tests_taken = self.tests_taken + 1

else:
self.skip_count = self.skip_count + 1
self.tests_taken = self.tests_taken + 1


def pytest_report_teststatus(self, report):
""" Called after every test for test case status"""

if report.passed:
if report.when == "call": # ignore setup/teardown
self.append_pass()

elif report.failed:
if report.when == "call":
self.append_failure(report)

else:
self.append_error()

elif report.skipped:
self.append_skipped(report)

if report.when in ("teardown"):
status = (self.tests_taken, self.tests_count, self.pass_count, self.fail_count,
self.skip_count, self.xpass_count, self.xfail_count, self.error_count)

msg = "%d of %d completed, %d Pass, %d Fail, %d Skip, %d XPass, %d XFail, %d Error" % (status)
self.write_sep("_", msg)


def pytest_collectreport(self, report):
# Show errors occurred during the collection instantly.
TerminalReporter.pytest_collectreport(self, report)
if report.failed:
self.rewrite("") # erase the "collecting" message
self.print_failure(report)


def pytest_runtest_logreport(self, report):
# Show failures and errors occuring during running a test
# instantly.
TerminalReporter.pytest_runtest_logreport(self, report)
if report.failed and not hasattr(report, 'wasxfail'):
if self.verbosity <= 0:
self._tw.line()
self.print_failure(report)


def summary_failures(self):
# Prevent failure summary from being shown since we already
# show the failure instantly after failure has occured.
pass


def summary_errors(self):
# Prevent error summary from being shown since we already
# show the error instantly after error has occured.
pass


def print_failure(self, report):
if self.config.option.tbstyle != "no":
if self.config.option.tbstyle == "line":
line = self._getcrashline(report)
self.write_line(line)
else:
msg = self._getfailureheadline(report)
if not hasattr(report, 'when'):
msg = "ERROR collecting " + msg
elif report.when == "setup":
msg = "ERROR at setup of " + msg
elif report.when == "teardown":
msg = "ERROR at teardown of " + msg
self.write_sep("_", msg)
if not self.config.getvalue("usepdb"):
self._outrep_summary(report)
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[bdist_wheel]
universal = 1
48 changes: 48 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import os

from setuptools import setup


def get_version(filename):

here = os.path.dirname(os.path.abspath(__file__))
f = open(os.path.join(here, filename))
version_match = f.read()
f.close()

if version_match:
return version_match
raise RuntimeError("Unable to find version string.")



setup(name='pytest-progress',
version=get_version('version.txt'),
description='pytest plugin for instant test progress status',
long_description=unicode(open('README.rst').read(), errors='ignore'),
author='santosh',
author_email=u'[email protected]',
url=u'https://github.com/ssrikanta/pytest-progress',
py_modules=['pytest_progress'],
entry_points={'pytest11': ['progress = pytest_progress']},
install_requires=['pytest>=2.7'],
keywords='py.test pytest report',
classifiers=[
'Development Status :: 4 - Beta',
'Framework :: Pytest',
'Intended Audience :: Developers',
'Operating System :: POSIX',
'Operating System :: Microsoft :: Windows',
'Operating System :: MacOS :: MacOS X',
'Topic :: Software Development :: Testing',
'Topic :: Software Development :: Quality Assurance',
'Topic :: Software Development :: Libraries',
'Topic :: Utilities',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
]
)

30 changes: 30 additions & 0 deletions test_progress_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

import pytest


class Test_Progress_Report(object):


def test_progress_report_01(self):
assert True


@pytest.mark.xfail(reason="passed Simply")
def test_progress_report_02(self):
assert True


@pytest.mark.skip(reason="Skip for No Reason")
def test_progress_report_03(self):
assert True


@pytest.mark.xfail(reason="Failed Simply")
def test_progress_report_04(self):
assert False


def test_progress_report_05(self):
assert True is False


24 changes: 24 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Tox (http://tox.testrun.org/) is a tool for running tests
# in multiple virtualenvs. This configuration file will run the
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.

[tox]
envlist = py27-pytest29-supported-xdist,
py27-pytest29-unsupported-xdist,
py34-pytest29-supported-xdist,
py35-pytest29-supported-xdist,
py35-pytest29-unsupported-xdist,
pypy-pytest29-supported-xdist

[testenv]
passenv = CI TRAVIS_BUILD_ID TRAVIS TRAVIS_BRANCH TRAVIS_JOB_NUMBER TRAVIS_PULL_REQUEST TRAVIS_JOB_ID TRAVIS_REPO_SLUG TRAVIS_COMMIT
deps =
pytest29: pytest>=2.9,<2.10
openpyxl
supported-xdist: pytest-xdist>=1.14
unsupported-xdist: pytest-xdist<1.14
pytest-rerunfailures
commands =
py.test --cov=./ {posargs:test_excel_report.py}
codecov -e TOXENV
1 change: 1 addition & 0 deletions version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.0

0 comments on commit 08b400c

Please sign in to comment.