From 94c1de61dae09bcd859b38be3d87b418b07fce09 Mon Sep 17 00:00:00 2001 From: xiangshuaizhx Date: Sat, 7 Mar 2020 12:43:01 +0800 Subject: [PATCH] package init --- 0001-Add-boolean-matchers.patch | 134 -------------------------------- python-hamcrest.spec | 57 +++++++------- 2 files changed, 26 insertions(+), 165 deletions(-) delete mode 100644 0001-Add-boolean-matchers.patch diff --git a/0001-Add-boolean-matchers.patch b/0001-Add-boolean-matchers.patch deleted file mode 100644 index f3fdde2..0000000 --- a/0001-Add-boolean-matchers.patch +++ /dev/null @@ -1,134 +0,0 @@ -From 37a4d0dbeb9a92b959edfb9b1aceba4eaacf9f78 Mon Sep 17 00:00:00 2001 -From: Alex Panov -Date: Sun, 15 May 2016 23:36:18 -0400 -Subject: [PATCH] Add boolean matchers - ---- - README.rst | 5 ++++ - src/hamcrest/library/__init__.py | 3 ++ - src/hamcrest/library/bool/__init__.py | 1 + - src/hamcrest/library/bool/bool_comparison.py | 22 ++++++++++++++ - tests/hamcrest_unit_test/bool/__init__.py | 0 - .../bool/bool_comparison_test.py | 34 ++++++++++++++++++++++ - 6 files changed, 65 insertions(+) - create mode 100644 src/hamcrest/library/bool/__init__.py - create mode 100644 src/hamcrest/library/bool/bool_comparison.py - create mode 100644 tests/hamcrest_unit_test/bool/__init__.py - create mode 100644 tests/hamcrest_unit_test/bool/bool_comparison_test.py - -diff --git a/README.rst b/README.rst -index 8ef46bb..d2200f8 100644 ---- a/README.rst -+++ b/README.rst -@@ -148,6 +148,11 @@ PyHamcrest comes with a library of useful matchers: - * ``greater_than``, ``greater_than_or_equal_to``, ``less_than``, - ``less_than_or_equal_to`` - match numeric ordering - -+* Boolean -+ -+ * ``is_true`` - verify the value is True -+ * ``is_false`` - verify the value is False -+ - * Text - - * ``contains_string`` - match part of a string -diff --git a/src/hamcrest/library/__init__.py b/src/hamcrest/library/__init__.py -index a5a7963..55dfcda 100644 ---- a/src/hamcrest/library/__init__.py -+++ b/src/hamcrest/library/__init__.py -@@ -7,6 +7,7 @@ from hamcrest.library.integration import * - from hamcrest.library.number import * - from hamcrest.library.object import * - from hamcrest.library.text import * -+from hamcrest.library.bool import * - - __author__ = "Jon Reid" - __copyright__ = "Copyright 2011 hamcrest.org" -@@ -41,4 +42,6 @@ __all__ = [ - 'ends_with', - 'starts_with', - 'string_contains_in_order', -+ 'is_true', -+ 'is_false' - ] -diff --git a/src/hamcrest/library/bool/__init__.py b/src/hamcrest/library/bool/__init__.py -new file mode 100644 -index 0000000..7cf13a3 ---- /dev/null -+++ b/src/hamcrest/library/bool/__init__.py -@@ -0,0 +1 @@ -+from .bool_comparison import is_true, is_false -diff --git a/src/hamcrest/library/bool/bool_comparison.py b/src/hamcrest/library/bool/bool_comparison.py -new file mode 100644 -index 0000000..af7e1b6 ---- /dev/null -+++ b/src/hamcrest/library/bool/bool_comparison.py -@@ -0,0 +1,22 @@ -+from hamcrest.core.base_matcher import BaseMatcher -+ -+ -+class IsABool(BaseMatcher): -+ def __init__(self, boolean_value): -+ self.boolean_value = boolean_value -+ -+ def describe_to(self, description): -+ description.append_text(str(self.boolean_value)) -+ -+ def _matches(self, item): -+ if not isinstance(item, bool): -+ return False -+ return item == self.boolean_value -+ -+ -+def is_true(): -+ return IsABool(True) -+ -+ -+def is_false(): -+ return IsABool(False) -diff --git a/tests/hamcrest_unit_test/bool/__init__.py b/tests/hamcrest_unit_test/bool/__init__.py -new file mode 100644 -index 0000000..e69de29 -diff --git a/tests/hamcrest_unit_test/bool/bool_comparison_test.py b/tests/hamcrest_unit_test/bool/bool_comparison_test.py -new file mode 100644 -index 0000000..e865365 ---- /dev/null -+++ b/tests/hamcrest_unit_test/bool/bool_comparison_test.py -@@ -0,0 +1,34 @@ -+from hamcrest import assert_that, equal_to -+from hamcrest.core.string_description import StringDescription -+from hamcrest.library.bool import is_false, is_true -+from hamcrest_unit_test.matcher_test import MatcherTest -+ -+ -+class BoolComparisonTest(MatcherTest): -+ def test_true_is_true(self): -+ self.assert_matches('Is True', is_true(), True) -+ -+ def test_false_is_not_true(self): -+ self.assert_does_not_match('False', is_true(), False) -+ -+ def test_false_is_false(self): -+ self.assert_matches('False', is_false(), False) -+ -+ def test_true_is_not_false(self): -+ self.assert_does_not_match('True', is_false(), True) -+ -+ def test_number_is_not_true(self): -+ self.assert_does_not_match('True', is_true(), 1) -+ -+ def test_number_is_not_false(self): -+ self.assert_does_not_match('False', is_false(), 1) -+ -+ def test_is_true_description(self): -+ description = StringDescription() -+ is_true().describe_to(description) -+ assert_that(str(description), equal_to('True')) -+ -+ def test_is_false_description(self): -+ description = StringDescription() -+ is_false().describe_to(description) -+ assert_that(str(description), equal_to('False')) --- -2.9.3 - diff --git a/python-hamcrest.spec b/python-hamcrest.spec index 3f64fc0..6591cf5 100644 --- a/python-hamcrest.spec +++ b/python-hamcrest.spec @@ -1,46 +1,39 @@ -Name: python-hamcrest -Version: 1.9.0 -Release: 8 -Summary: Hamcrest matchers for Python -License: BSD -URL: https://github.com/hamcrest/PyHamcrest -Source0: https://github.com/hamcrest/PyHamcrest/archive/V1.9.0/%{name}-1.9.0.tar.gz -Patch0001: 0001-Add-boolean-matchers.patch -BuildArch: noarch +Name: python-hamcrest +Version: 1.9.0 +Release: 8 +Summary: Hamcrest matchers for Python +License: BSD +URL: https://github.com/hamcrest/PyHamcrest +Source0: %{url}/archive/V%{version}/%{name}-%{version}.tar.gz + +BuildArch: noarch %description PyHamcrest is a framework for writing matcher objects, allowing you to -declaratively define "match" rules. There are a number of situations -where matchers are invaluable, such as UI validation, or data filtering, -but it is in the area of writing flexible tests that matchers are most -commonly used. +declaratively define "match" rules. There are a number of situations where +matchers are invaluable, such as UI validation, or data filtering, but it is +in the area of writing flexible tests that matchers are most commonly used. %package -n python2-hamcrest -Summary: Hamcrest matchers for Python +Summary: Hamcrest matchers for Python2 %{?python_provide:%python_provide python2-hamcrest} -BuildRequires: python2-devel python2-setuptools python2-pytest python2-mock python2-six -Requires: python2-six +BuildRequires: python2-devel python2-setuptools python2-pytest python2-mock python2-six +Requires: python2-six %description -n python2-hamcrest PyHamcrest is a framework for writing matcher objects, allowing you to -declaratively define "match" rules. There are a number of situations -where matchers are invaluable, such as UI validation, or data filtering, -but it is in the area of writing flexible tests that matchers are most -commonly used. +declaratively define "match" rules. Python 2 version. %package -n python3-hamcrest -Summary: Hamcrest matchers for Python +Summary: Hamcrest matchers for Python3 %{?python_provide:%python_provide python3-hamcrest} -BuildRequires: python3-devel python3-setuptools python3-pytest python3-mock python3-six -Requires: python3-six +BuildRequires: python3-devel python3-setuptools python3-pytest python3-mock python3-six +Requires: python3-six %description -n python3-hamcrest PyHamcrest is a framework for writing matcher objects, allowing you to -declaratively define "match" rules. There are a number of situations -where matchers are invaluable, such as UI validation, or data filtering, -but it is in the area of writing flexible tests that matchers are most -commonly used. +declaratively define "match" rules. Python 3 version. %prep @@ -60,11 +53,13 @@ PYTHONPATH=%{buildroot}%{python2_sitelib} py.test-%{python2_version} -v PYTHONPATH=%{buildroot}%{python3_sitelib} py.test-%{python3_version} -v %files -n python2-hamcrest -%{python2_sitelib}/* +%{python2_sitelib}/PyHamcrest-*.egg-info/ +%{python2_sitelib}/hamcrest/ %files -n python3-hamcrest -%{python3_sitelib}/* +%{python3_sitelib}/PyHamcrest-*.egg-info/ +%{python3_sitelib}/hamcrest/ %changelog -* Fri Feb 21 2020 likexin - 1.9.0-8 -- package init +* Fri Feb 28 2020 wangzhishun - 1.9.0-8 +- Package init \ No newline at end of file -- Gitee