From add19ba81f86c22c695e47903e5e81bd8857d25b6c8aebc736251381e3a4eba8 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Fri, 20 Oct 2023 10:26:56 +0000 Subject: [PATCH 1/3] - Clean up the SPEC file OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-flaky?expand=0&rev=21 --- python-flaky.changes | 5 +++++ python-flaky.spec | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/python-flaky.changes b/python-flaky.changes index 0fe6e3f..3f07860 100644 --- a/python-flaky.changes +++ b/python-flaky.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Fri Oct 20 10:26:48 UTC 2023 - Matej Cepl + +- Clean up the SPEC file + ------------------------------------------------------------------- Fri Apr 21 12:25:08 UTC 2023 - Dirk Müller diff --git a/python-flaky.spec b/python-flaky.spec index 10869a9..6b06ba5 100644 --- a/python-flaky.spec +++ b/python-flaky.spec @@ -16,7 +16,7 @@ # -%{?!python_module:%define python_module() python-%{**} python3-%{**}} +%{?sle15_python_module_pythons} %global flavor @BUILD_FLAVOR@%{nil} %if "%{flavor}" == "test" %define psuffix -test @@ -24,7 +24,6 @@ %else %bcond_with test %endif -%{?sle15_python_module_pythons} Name: python-flaky%{?psuffix} Version: 3.7.0 Release: 0 @@ -88,7 +87,8 @@ export PYTEST_ADDOPTS="--force-flaky --max-runs 2" %files %{python_files} %doc README.rst %license LICENSE -%{python_sitelib}/* +%{python_sitelib}/flaky +%{python_sitelib}/flaky-%{version}*-info %endif %changelog From 825ec7d284074e285114c9e3606f2ac583f329441f90e0e439f74028bdc81587 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Fri, 20 Oct 2023 12:02:29 +0000 Subject: [PATCH 2/3] - Add remove_genty.patch to remove dependency on the external genty package. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-flaky?expand=0&rev=22 --- python-flaky.changes | 6 ++ python-flaky.spec | 8 +- remove_genty.patch | 219 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 230 insertions(+), 3 deletions(-) create mode 100644 remove_genty.patch diff --git a/python-flaky.changes b/python-flaky.changes index 3f07860..34cfe47 100644 --- a/python-flaky.changes +++ b/python-flaky.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Fri Oct 20 10:57:54 UTC 2023 - Matej Cepl + +- Add remove_genty.patch to remove dependency on the external + genty package. + ------------------------------------------------------------------- Fri Oct 20 10:26:48 UTC 2023 - Matej Cepl diff --git a/python-flaky.spec b/python-flaky.spec index 6b06ba5..37f46e6 100644 --- a/python-flaky.spec +++ b/python-flaky.spec @@ -34,16 +34,18 @@ Source: https://files.pythonhosted.org/packages/source/f/flaky/flaky-%{v # PATCH-FEATURE-UPSTREAM remove_nose.patch gh#box/flaky#171 mcepl@suse.com # remove dependency on nose Patch0: remove_nose.patch -# PATCH-FEATURE-UPSTREAM remove_mock.patch gh#box/flaky#171 mcepl@suse.com -# this patch makes things totally awesome +# PATCH-FEATURE-UPSTREAM remove_mock.patch bsc#[0-9]+ mcepl@suse.com +# remove dependency on the external mock package Patch1: remove_mock.patch +# PATCH-FEATURE-UPSTREAM remove_genty.patch bsc#[0-9]+ mcepl@suse.com +# remove dependency on the external genty package +Patch2: remove_genty.patch BuildRequires: %{python_module setuptools} BuildRequires: fdupes BuildRequires: python-rpm-macros BuildArch: noarch %if %{with test} BuildRequires: %{python_module flaky >= %{version}} -BuildRequires: %{python_module genty} BuildRequires: %{python_module pytest} %if 0%{?suse_version} <= 1500 BuildRequires: python-mock diff --git a/remove_genty.patch b/remove_genty.patch new file mode 100644 index 0000000..cd5e222 --- /dev/null +++ b/remove_genty.patch @@ -0,0 +1,219 @@ +--- + test/test_flaky_plugin.py | 82 +++++++++++++++++------------------- + test/test_multiprocess_string_io.py | 51 +++++++++------------- + test/test_utils.py | 17 +++---- + 3 files changed, 69 insertions(+), 81 deletions(-) + +--- a/test/test_flaky_plugin.py ++++ b/test/test_flaky_plugin.py +@@ -2,17 +2,32 @@ + + from __future__ import unicode_literals + ++from collections import namedtuple + from io import StringIO + from unittest import TestCase + + from flaky._flaky_plugin import _FlakyPlugin + from flaky.names import FlakyNames + +-from genty import genty, genty_dataset +- ++TestCaseDataset = namedtuple("TestCaseDataset", ++ ['max_runs', 'min_passes', 'current_runs', 'current_passes', 'expect_fail']) + + @genty + class TestFlakyPlugin(TestCase): ++ _test_dataset = ( ++ "default_not_started": TestCaseDataset(2, 1, 0, 0, False), ++ "default_one_failure": TestCaseDataset(2, 1, 1, 0, False), ++ "default_one_success": TestCaseDataset(2, 1, 1, 1, False), ++ "default_two_failures": TestCaseDataset(2, 1, 2, 0, True), ++ "default_one_failure_one_success": TestCaseDataset(2, 1, 2, 1, False), ++ "three_two_not_started": TestCaseDataset(3, 2, 0, 0, False), ++ "three_two_one_failure": TestCaseDataset(3, 2, 1, 0, False), ++ "three_two_one_success": TestCaseDataset(3, 2, 1, 1, False), ++ "three_two_two_failures": TestCaseDataset(3, 2, 2, 0, True), ++ "three_two_one_failure_one_success": TestCaseDataset(3, 2, 2, 1, False), ++ "three_two_two_successes": TestCaseDataset(3, 2, 2, 2, False), ++ ) ++ + def setUp(self): + super(TestFlakyPlugin, self).setUp() + self._flaky_plugin = _FlakyPlugin() +@@ -28,43 +43,26 @@ class TestFlakyPlugin(TestCase): + mock_message, + ) + +- @genty_dataset( +- default_not_started=(2, 1, 0, 0, False), +- default_one_failure=(2, 1, 1, 0, False), +- default_one_success=(2, 1, 1, 1, False), +- default_two_failures=(2, 1, 2, 0, True), +- default_one_failure_one_success=(2, 1, 2, 1, False), +- three_two_not_started=(3, 2, 0, 0, False), +- three_two_one_failure=(3, 2, 1, 0, False), +- three_two_one_success=(3, 2, 1, 1, False), +- three_two_two_failures=(3, 2, 2, 0, True), +- three_two_one_failure_one_success=(3, 2, 2, 1, False), +- three_two_two_successes=(3, 2, 2, 2, False), +- ) +- def test_flaky_plugin_identifies_failure( +- self, +- max_runs, +- min_passes, +- current_runs, +- current_passes, +- expect_fail, +- ): +- flaky = { +- FlakyNames.CURRENT_PASSES: current_passes, +- FlakyNames.CURRENT_RUNS: current_runs, +- FlakyNames.MAX_RUNS: max_runs, +- FlakyNames.MIN_PASSES: min_passes, +- } +- # pylint:disable=protected-access +- self.assertEqual( +- 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) ++ def test_flaky_plugin_identifies_failure(self): ++ for test in _test_dataset: ++ with self.subTest(test): ++ flaky = { ++ FlakyNames.CURRENT_PASSES: _test_dataset[test].current_passes, ++ FlakyNames.CURRENT_RUNS: _test_dataset[test].current_runs, ++ FlakyNames.MAX_RUNS: _test_dataset[test].max_runs, ++ FlakyNames.MIN_PASSES: _test_dataset[test].min_passes, ++ } ++ # pylint:disable=protected-access ++ self.assertEqual( ++ self._flaky_plugin._has_flaky_test_failed(flaky), ++ _test_dataset[test].expect_fail, ++ ) ++ ++ def test_write_unicode_to_stream(self): ++ for message in ('ascii stuff', 'ńőń ȁŝćȉȉ ŝƭȕƒƒ'): ++ with self.subTest(message): ++ stream = StringIO() ++ stream.write('ascii stuff') ++ # pylint:disable=protected-access ++ self._flaky_plugin._stream.write(message) ++ self._flaky_plugin._add_flaky_report(stream) +--- a/test/test_multiprocess_string_io.py ++++ b/test/test_multiprocess_string_io.py +@@ -5,13 +5,18 @@ from __future__ import unicode_literals + from io import StringIO + from unittest import TestCase + +-from genty import genty, genty_dataset + +- +-@genty + class TestMultiprocessStringIO(TestCase): + _unicode_string = 'Plain Hello' + _unicode_string_non_ascii = 'ńőń ȁŝćȉȉ ŝƭȕƒƒ' ++ _test_values = { ++ "no_writes": ([], ''), ++ "one_write": ([_unicode_string], _unicode_string), ++ "two_writes": ( ++ [_unicode_string, _unicode_string_non_ascii], ++ '{}{}'.format(_unicode_string, _unicode_string_non_ascii), ++ ) ++ } + + def setUp(self): + super(TestMultiprocessStringIO, self).setUp() +@@ -21,29 +26,17 @@ class TestMultiprocessStringIO(TestCase) + del self._mp_string_io.proxy[:] + self._string_ios = (self._string_io, self._mp_string_io) + +- @genty_dataset( +- no_writes=([], ''), +- one_write=([_unicode_string], _unicode_string), +- two_writes=( +- [_unicode_string, _unicode_string_non_ascii], +- '{}{}'.format(_unicode_string, _unicode_string_non_ascii), +- ) +- ) +- def test_write_then_read(self, writes, expected_value): +- for string_io in self._string_ios: +- for item in writes: +- string_io.write(item) +- self.assertEqual(string_io.getvalue(), expected_value) +- +- @genty_dataset( +- no_writes=([], ''), +- one_write=([_unicode_string], _unicode_string), +- two_writes=( +- [_unicode_string, _unicode_string_non_ascii], +- '{}{}'.format(_unicode_string, _unicode_string_non_ascii), +- ) +- ) +- def test_writelines_then_read(self, lines, expected_value): +- for string_io in self._string_ios: +- string_io.writelines(lines) +- self.assertEqual(string_io.getvalue(), expected_value) ++ def test_write_then_read(self): ++ for name in _test_values: ++ with self.subTest(name): ++ for string_io in self._string_ios: ++ for item in _test_values[name][0]: ++ string_io.write(item) ++ self.assertEqual(string_io.getvalue(), _test_values[name][1]) ++ ++ def test_writelines_then_read(self): ++ for name in _test_values: ++ with self.subTest(name): ++ for string_io in self._string_ios: ++ string_io.writelines(_test_values[name][0]) ++ self.assertEqual(string_io.getvalue(), _test_values[name][1]) +--- a/test/test_utils.py ++++ b/test/test_utils.py +@@ -7,10 +7,7 @@ from unittest import TestCase + + from flaky.utils import ensure_unicode_string, unicode_type + +-from genty import genty, genty_dataset + +- +-@genty + class TestEnsureUnicodeString(TestCase): + _unicode_string = 'Plain Hello' + _byte_string = b'Plain Hello' +@@ -19,6 +16,13 @@ class TestEnsureUnicodeString(TestCase): + _hello = 'Hèllö' + _mangled_hello = 'H\ufffdll\ufffd' + _byte_string_windows_encoded = _hello.encode('windows-1252') ++ _test_dataset = ( ++ (_unicode_string, _unicode_string), ++ (_byte_string, _unicode_string), ++ (_unicode_string_non_ascii, _unicode_string_non_ascii), ++ (_byte_string_non_ascii, _unicode_string_non_ascii), ++ (_byte_string_windows_encoded, _mangled_hello), ++ ) + + def test_ensure_unicode_string_handles_nonascii_exception_message(self): + message = '\u2013' +@@ -30,13 +34,6 @@ class TestEnsureUnicodeString(TestCase): + message = unicode_type(encoded_message) + self.assertEqual(string, message) + +- @genty_dataset( +- (_unicode_string, _unicode_string), +- (_byte_string, _unicode_string), +- (_unicode_string_non_ascii, _unicode_string_non_ascii), +- (_byte_string_non_ascii, _unicode_string_non_ascii), +- (_byte_string_windows_encoded, _mangled_hello), +- ) + def test_ensure_unicode_string_handles_various_strings( + self, + string, From de810d99096daee6d212f74baaa8e8a18ca12e5c494fb9344b7c9d4b582279bd Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Fri, 20 Oct 2023 12:28:18 +0000 Subject: [PATCH 3/3] genty package (gh#box/flaky!197). OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-flaky?expand=0&rev=23 --- python-flaky.changes | 2 +- python-flaky.spec | 4 ++-- remove_genty.patch | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/python-flaky.changes b/python-flaky.changes index 34cfe47..1fa37ee 100644 --- a/python-flaky.changes +++ b/python-flaky.changes @@ -2,7 +2,7 @@ Fri Oct 20 10:57:54 UTC 2023 - Matej Cepl - Add remove_genty.patch to remove dependency on the external - genty package. + genty package (gh#box/flaky!197). ------------------------------------------------------------------- Fri Oct 20 10:26:48 UTC 2023 - Matej Cepl diff --git a/python-flaky.spec b/python-flaky.spec index 37f46e6..6bcd9c8 100644 --- a/python-flaky.spec +++ b/python-flaky.spec @@ -34,10 +34,10 @@ Source: https://files.pythonhosted.org/packages/source/f/flaky/flaky-%{v # PATCH-FEATURE-UPSTREAM remove_nose.patch gh#box/flaky#171 mcepl@suse.com # remove dependency on nose Patch0: remove_nose.patch -# PATCH-FEATURE-UPSTREAM remove_mock.patch bsc#[0-9]+ mcepl@suse.com +# PATCH-FEATURE-UPSTREAM remove_mock.patch gh#box/flaky!197 mcepl@suse.com # remove dependency on the external mock package Patch1: remove_mock.patch -# PATCH-FEATURE-UPSTREAM remove_genty.patch bsc#[0-9]+ mcepl@suse.com +# PATCH-FEATURE-UPSTREAM remove_genty.patch gh#box/flaky!197 mcepl@suse.com # remove dependency on the external genty package Patch2: remove_genty.patch BuildRequires: %{python_module setuptools} diff --git a/remove_genty.patch b/remove_genty.patch index cd5e222..5969a46 100644 --- a/remove_genty.patch +++ b/remove_genty.patch @@ -1,12 +1,12 @@ --- - test/test_flaky_plugin.py | 82 +++++++++++++++++------------------- + test/test_flaky_plugin.py | 83 +++++++++++++++++------------------- test/test_multiprocess_string_io.py | 51 +++++++++------------- test/test_utils.py | 17 +++---- - 3 files changed, 69 insertions(+), 81 deletions(-) + 3 files changed, 69 insertions(+), 82 deletions(-) --- a/test/test_flaky_plugin.py +++ b/test/test_flaky_plugin.py -@@ -2,17 +2,32 @@ +@@ -2,17 +2,31 @@ from __future__ import unicode_literals @@ -18,11 +18,11 @@ from flaky.names import FlakyNames -from genty import genty, genty_dataset -- +TestCaseDataset = namedtuple("TestCaseDataset", + ['max_runs', 'min_passes', 'current_runs', 'current_passes', 'expect_fail']) - @genty +- +-@genty class TestFlakyPlugin(TestCase): + _test_dataset = ( + "default_not_started": TestCaseDataset(2, 1, 0, 0, False), @@ -41,7 +41,7 @@ def setUp(self): super(TestFlakyPlugin, self).setUp() self._flaky_plugin = _FlakyPlugin() -@@ -28,43 +43,26 @@ class TestFlakyPlugin(TestCase): +@@ -28,43 +42,26 @@ class TestFlakyPlugin(TestCase): mock_message, )