Skip to content

Commit

Permalink
Bugfix: flaky for nose could raise a KeyError at the end of a failed …
Browse files Browse the repository at this point in the history
…rerun test.
  • Loading branch information
Jeff-Meadows committed May 22, 2015
1 parent 8564a1b commit cb78ee2
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
8 changes: 8 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
Release History
---------------


2.1.0 (2015-05-05)
++++++++++++++++++

**Bugfixes**

- Flaky will no longer raise a KeyError for failed flaky tests.

2.1.0 (2015-05-05)
++++++++++++++++++

Expand Down
2 changes: 1 addition & 1 deletion flaky/flaky_nose_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def stopTest(self, test):
# pylint:disable=invalid-name
if self._test_status[test]:
test.run(self._flaky_result)
del self._test_status[test]
self._test_status.pop(test, None)

def _rerun_test(self, test):
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def main():
base_dir = dirname(__file__)
setup(
name='flaky',
version='2.1.0',
version='2.1.1',
description='Plugin for nose or py.test that automatically reruns flaky tests.',
long_description=open(join(base_dir, 'README.rst')).read(),
author='Box',
Expand Down
14 changes: 14 additions & 0 deletions test/test_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# This is an end-to-end example of the flaky package in action. Consider it
# a live tutorial, showing the various features in action.

from genty import genty, genty_dataset

from flaky import flaky
from test.base_test_case import TestCase, expectedFailure, skip

Expand Down Expand Up @@ -85,3 +87,15 @@ def test_flaky_function(param=[]):
param_length = len(param)
param.append(None)
assert param_length == 1


@genty
class ExampleFlakyTestsWithUnicodeTestNames(ExampleFlakyTests):
@genty_dataset('ascii name', 'ńőń ȁŝćȉȉ ŝƭȕƒƒ')
def test_non_flaky_thing(self, message):
# pylint:disable=unused-argument
self._threshold += 1
if self._threshold < 1:
raise Exception("Threshold is not high enough: {0} vs {1}.".format(
self._threshold, 1),
)
11 changes: 10 additions & 1 deletion test/test_flaky_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from __future__ import unicode_literals
from genty import genty, genty_dataset
from io import StringIO
from flaky._flaky_plugin import _FlakyPlugin
from flaky.names import FlakyNames
from test.base_test_case import TestCase
Expand All @@ -21,7 +22,7 @@ def test_flaky_plugin_handles_non_ascii_byte_string_in_exception(self):
self._flaky_plugin._log_test_failure(
mock_method_name,
(ValueError.__name__, mock_exception, ''),
mock_message
mock_message,
)

@genty_dataset(
Expand Down Expand Up @@ -56,3 +57,11 @@ def test_flaky_plugin_identifies_failure(
self._flaky_plugin._has_flaky_test_failed(flaky),
expect_fail,
)

@genty_dataset('ascii stuff', 'ńőń ȁŝćȉȉ ŝƭȕƒƒ')
def test_write_unicode_to_stream(self, message):
stream = StringIO()
stream.write('ascii stuff')
# pylint:disable=protected-access
self._flaky_plugin._stream.write(message)
self._flaky_plugin._add_flaky_report(stream)

0 comments on commit cb78ee2

Please sign in to comment.