[Python-modules-commits] [python-flaky] 01/04: Import python-flaky_3.3.0.orig.tar.gz
Tristan Seligmann
mithrandi at moszumanska.debian.org
Sat Aug 27 11:25:13 UTC 2016
This is an automated email from the git hooks/post-receive script.
mithrandi pushed a commit to branch master
in repository python-flaky.
commit c364537a2a079e825f0e372475bdc759e8aa372e
Author: Tristan Seligmann <mithrandi at mithrandi.net>
Date: Sat Aug 27 13:13:19 2016 +0200
Import python-flaky_3.3.0.orig.tar.gz
---
AUTHORS.rst | 1 +
HISTORY.rst | 19 +++++++++++++++++++
flaky/_flaky_plugin.py | 41 ++++++++++++++++++++++++++++++++---------
flaky/flaky_nose_plugin.py | 25 ++++++-------------------
flaky/flaky_pytest_plugin.py | 44 ++++++++++++++++++--------------------------
setup.py | 2 +-
6 files changed, 77 insertions(+), 55 deletions(-)
diff --git a/AUTHORS.rst b/AUTHORS.rst
index 161487f..7c0f281 100644
--- a/AUTHORS.rst
+++ b/AUTHORS.rst
@@ -3,3 +3,4 @@ our testing framework. This is a list of contributors.
- `@Jeff-Meadows <https://github.com/Jeff-Meadows>`_
- `@benpatterson <https://github.com/benpatterson>`_
+- `@amygdalama <https://github.com/amygdalama>`_
diff --git a/HISTORY.rst b/HISTORY.rst
index f378690..34449c1 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -6,6 +6,25 @@ Release History
Upcoming
++++++++
+3.3.0 (2016-07-28)
+++++++++++++++++++
+
+- Flaky for Nose will now rerun tests using the ``afterTest`` plugin hook, rather than the ``stopTest`` hook.
+ The ``afterTest`` hook is called slightly later in the test run process; this change allows flaky to be used
+ with `TestCase` subclasses that override the test run process, and do teardown after ``stopTest`` is called.
+ In particular, this means that flaky is now compatible with Django's ``LiveServerTestCase``.
+
+
+3.2.0 (2016-07-21)
+++++++++++++++++++
+
+- Flaky will completely suppress the flaky report if ``--no-success-flaky-report`` is specified and no tests
+ needed to be rerun.
+
+**Bugfixes**
+- Flaky will no longer cause ``py.test --pep8`` to fail.
+
+
3.1.0 (2016-22-11)
++++++++++++++++++
diff --git a/flaky/_flaky_plugin.py b/flaky/_flaky_plugin.py
index cc329a1..1adac9b 100644
--- a/flaky/_flaky_plugin.py
+++ b/flaky/_flaky_plugin.py
@@ -176,7 +176,7 @@ class _FlakyPlugin(object):
`bool`
"""
try:
- _, _, name = self._get_test_declaration_callable_and_name(test)
+ name = self._get_test_callable_name(test)
except AttributeError:
return False
@@ -266,7 +266,7 @@ class _FlakyPlugin(object):
`bool`
"""
try:
- _, _, name = self._get_test_declaration_callable_and_name(test)
+ name = self._get_test_callable_name(test)
except AttributeError:
return False
need_reruns = self._should_handle_test_success(test)
@@ -377,13 +377,19 @@ class _FlakyPlugin(object):
:type stream:
`file`
"""
+ value = self._stream.getvalue()
+
+ # If everything succeeded and --no-success-flaky-report is specified
+ # don't print anything.
+ if not self._flaky_success_report and not value:
+ return
+
stream.write('===Flaky Test Report===\n\n')
# Python 2 will write to the stderr stream as a byte string, whereas
# Python 3 will write to the stream as text. Only encode into a byte
# string if the write tries to encode it first and raises a
# UnicodeEncodeError.
- value = self._stream.getvalue()
try:
stream.write(value)
except UnicodeEncodeError:
@@ -401,7 +407,9 @@ class _FlakyPlugin(object):
:type test:
:class:`nose.case.Test`
"""
- _, test_callable, _ = cls._get_test_declaration_callable_and_name(test)
+ test_callable = cls._get_test_callable(test)
+ if test_callable is None:
+ return
for attr, value in cls._get_flaky_attributes(test_class).items():
already_set = hasattr(test, attr)
if already_set:
@@ -568,19 +576,34 @@ class _FlakyPlugin(object):
return flaky[FlakyNames.CURRENT_PASSES] >= flaky[FlakyNames.MIN_PASSES]
@classmethod
- def _get_test_declaration_callable_and_name(cls, test):
+ def _get_test_callable(cls, test):
"""
- Get the test declaration, the test callable,
- and test callable name from the test.
+ Get the test callable, from the test.
:param test:
The test that has raised an error or succeeded
:type test:
- :class:`nose.case.Test` or :class:`Function`
+ :class:`nose.case.Test` or :class:`pytest.Item`
:return:
The test declaration, callable and name that is being run
:rtype:
- `tuple` of `object`, `callable`, `unicode`
+ `callable`
+ """
+ raise NotImplementedError # pragma: no cover
+
+ @staticmethod
+ def _get_test_callable_name(test):
+ """
+ Get the name of the test callable from the test.
+
+ :param test:
+ The test that has raised an error or succeeded
+ :type test:
+ :class:`nose.case.Test` or :class:`pytest.Item`
+ :return:
+ The name of the test callable that is being run by the test
+ :rtype:
+ `unicode`
"""
raise NotImplementedError # pragma: no cover
diff --git a/flaky/flaky_nose_plugin.py b/flaky/flaky_nose_plugin.py
index 48789a2..16c62f5 100644
--- a/flaky/flaky_nose_plugin.py
+++ b/flaky/flaky_nose_plugin.py
@@ -85,7 +85,7 @@ class FlakyPlugin(_FlakyPlugin, Plugin):
Base class override. Called before a test is run.
Add the test to the test status tracker, so it can potentially
- be rerun during stopTest.
+ be rerun during afterTest.
:param test:
The test that is going to be run.
@@ -95,7 +95,7 @@ class FlakyPlugin(_FlakyPlugin, Plugin):
# pylint:disable=invalid-name
self._test_status[test] = None
- def stopTest(self, test):
+ def afterTest(self, test):
"""
Base class override. Called after a test is run.
@@ -117,7 +117,7 @@ class FlakyPlugin(_FlakyPlugin, Plugin):
Base class override. Rerun a flaky test.
In this case, don't actually rerun the test, but mark it for
- rerun during stopTest.
+ rerun during afterTest.
:param test:
The test that is going to be rerun.
@@ -251,16 +251,7 @@ class FlakyPlugin(_FlakyPlugin, Plugin):
@staticmethod
def _get_test_callable_name(test):
"""
- Get the name of the test callable from the test.
-
- :param test:
- The test that has raised an error or succeeded
- :type test:
- :class:`nose.case.Test`
- :return:
- The name of the test callable that is being run by the test
- :rtype:
- `unicode`
+ Base class override.
"""
_, _, class_and_callable_name = test.address()
first_dot_index = class_and_callable_name.find('.')
@@ -268,7 +259,7 @@ class FlakyPlugin(_FlakyPlugin, Plugin):
return test_callable_name
@classmethod
- def _get_test_declaration_callable_and_name(cls, test):
+ def _get_test_callable(cls, test):
"""
Base class override.
@@ -276,10 +267,6 @@ class FlakyPlugin(_FlakyPlugin, Plugin):
The test that has raised an error or succeeded
:type test:
:class:`nose.case.Test`
- :return:
- The test declaration, callable and name that is being run
- :rtype:
- `tuple` of `object`, `callable`, `unicode`
"""
callable_name = cls._get_test_callable_name(test)
test_callable = getattr(
@@ -287,4 +274,4 @@ class FlakyPlugin(_FlakyPlugin, Plugin):
callable_name,
getattr(test.test, 'test', test.test),
)
- return test_callable, test_callable, callable_name
+ return test_callable
diff --git a/flaky/flaky_pytest_plugin.py b/flaky/flaky_pytest_plugin.py
index a9a1cdb..11a13dc 100644
--- a/flaky/flaky_pytest_plugin.py
+++ b/flaky/flaky_pytest_plugin.py
@@ -146,7 +146,7 @@ class FlakyPlugin(_FlakyPlugin):
:rtype:
((`type`, :class:`Exception`, :class:`Traceback`) or (None, None, None), `unicode`)
"""
- _, _, name = self._get_test_declaration_callable_and_name(item)
+ name = self._get_test_callable_name(item)
call_info = self._call_infos.get(item, {}).get(self._PYTEST_WHEN_CALL, None)
if call_info is not None and call_info.excinfo:
err = (call_info.excinfo.type, call_info.excinfo.value, call_info.excinfo.tb)
@@ -313,21 +313,12 @@ class FlakyPlugin(_FlakyPlugin):
@staticmethod
def _get_test_callable_name(test):
"""
- Get the name of the test callable from the test.
-
- :param test:
- The test that has raised an error or succeeded
- :type test:
- :class:`Function`
- :return:
- The name of the test callable that is being run by the test
- :rtype:
- `unicode`
+ Base class override.
"""
return test.name
@classmethod
- def _get_test_declaration_callable_and_name(cls, test):
+ def _get_test_callable(cls, test):
"""
Base class override.
@@ -349,24 +340,25 @@ class FlakyPlugin(_FlakyPlugin):
if hasattr(test_instance, callable_name):
# Test is a method of a class
def_and_callable = getattr(test_instance, callable_name)
- return def_and_callable, def_and_callable, callable_name
+ return def_and_callable
elif hasattr(test_instance, unparametrized_name):
# Test is a parametrized method of a class
def_and_callable = getattr(test_instance, unparametrized_name)
- return def_and_callable, def_and_callable, callable_name
- elif hasattr(test, 'runner') and hasattr(test.runner, 'run'):
- # Test is a doctest
- return test, test.runner.run, callable_name
- elif hasattr(test.module, callable_name):
- # Test is a function in a module
- def_and_callable = getattr(test.module, callable_name)
- return def_and_callable, def_and_callable, callable_name
- elif hasattr(test.module, unparametrized_name):
- # Test is a parametrized function in a module
- def_and_callable = getattr(test.module, unparametrized_name)
- return def_and_callable, def_and_callable, callable_name
+ return def_and_callable
+ elif hasattr(test, 'module'):
+ if hasattr(test.module, callable_name):
+ # Test is a function in a module
+ def_and_callable = getattr(test.module, callable_name)
+ return def_and_callable
+ elif hasattr(test.module, unparametrized_name):
+ # Test is a parametrized function in a module
+ def_and_callable = getattr(test.module, unparametrized_name)
+ return def_and_callable
+ elif hasattr(test, 'runtest'):
+ # Test is a doctest or other non-Function Item
+ return test.runtest
else:
- return None, None, callable_name
+ return None
def _mark_test_for_rerun(self, test):
"""Base class override. Rerun a flaky test."""
diff --git a/setup.py b/setup.py
index 6bf7997..4b559af 100644
--- a/setup.py
+++ b/setup.py
@@ -53,7 +53,7 @@ def main():
base_dir = dirname(__file__)
setup(
name='flaky',
- version='3.1.1',
+ version='3.3.0',
description='Plugin for nose or py.test that automatically reruns flaky tests.',
long_description=open(join(base_dir, 'README.rst')).read(),
author='Box',
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-flaky.git
More information about the Python-modules-commits
mailing list