Sync from SUSE:SLFO:Main python-PyHamcrest revision 7a98697dbe03dba82778fab4f05a0ab6

This commit is contained in:
Adrian Schröter 2024-05-03 19:51:40 +02:00
commit 9f6d0af652
5 changed files with 308 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

View File

@ -0,0 +1,125 @@
From 37a4d0dbeb9a92b959edfb9b1aceba4eaacf9f78 Mon Sep 17 00:00:00 2001
From: Alex Panov <thealexpanov@gmail.com>
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
Index: PyHamcrest-2.0.2/README.rst
===================================================================
--- PyHamcrest-2.0.2.orig/README.rst
+++ PyHamcrest-2.0.2/README.rst
@@ -182,6 +182,11 @@ PyHamcrest comes with a library of usefu
* ``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
Index: PyHamcrest-2.0.2/src/hamcrest/library/__init__.py
===================================================================
--- PyHamcrest-2.0.2.orig/src/hamcrest/library/__init__.py
+++ PyHamcrest-2.0.2/src/hamcrest/library/__init__.py
@@ -6,6 +6,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",
]
Index: PyHamcrest-2.0.2/src/hamcrest/library/bool/__init__.py
===================================================================
--- /dev/null
+++ PyHamcrest-2.0.2/src/hamcrest/library/bool/__init__.py
@@ -0,0 +1 @@
+from .bool_comparison import is_true, is_false
Index: PyHamcrest-2.0.2/src/hamcrest/library/bool/bool_comparison.py
===================================================================
--- /dev/null
+++ PyHamcrest-2.0.2/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)
Index: PyHamcrest-2.0.2/tests/hamcrest_unit_test/bool/bool_comparison_test.py
===================================================================
--- /dev/null
+++ PyHamcrest-2.0.2/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'))

BIN
V2.0.3.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

90
python-PyHamcrest.changes Normal file
View File

@ -0,0 +1,90 @@
-------------------------------------------------------------------
Fri Apr 21 12:20:58 UTC 2023 - Dirk Müller <dmueller@suse.com>
- add sle15_python_module_pythons (jsc#PED-68)
-------------------------------------------------------------------
Thu Apr 7 06:52:55 UTC 2022 - pgajdos@suse.com
- version update to 2.0.3
* Features ^^^^^^^^
- * Adds the tests to the sdist. Fixed by #150
`#141 <https://github.com/hamcrest/PyHamcrest/issues/141>`_
- * Update the CI to test Python 3.10
`#160 <https://github.com/hamcrest/PyHamcrest/issues/160>`_
- * Add pretty string representation for matchers objects
`#170 <https://github.com/hamcrest/PyHamcrest/issues/170>`_
* Bugfixes ^^^^^^^^
- * Test coverage is now submitted to codecov.io.
`#135 <https://github.com/hamcrest/PyHamcrest/issues/135>`_
- Change to the ``has_entry()`` matcher - if exactly one key matches, but the value does not, report only the mismatching
value.
`#156 <https://github.com/hamcrest/PyHamcrest/issues/156>`_
- * Fix is_() type annotations
-------------------------------------------------------------------
Thu Mar 26 16:28:58 UTC 2020 - Marketa Calabkova <mcalabkova@suse.com>
- Update to 2.0.2
* Make hamcrest package PEP 561 compatible, i.e. supply type hints for external use.
* Drop formal support for 2.x
* Drop formal support for 3.x < 3.5
* Made has_properties() report all mismatches, not just the first.
* Silence warnings.
* Type fixes.
* Remove obsolete dependencies.
* Add support up to Python 3.8
- Removed upstreamed patch pytest4-02.patch
-------------------------------------------------------------------
Thu Nov 21 12:06:53 CET 2019 - Matej Cepl <mcepl@suse.com>
- Remove pytest4.patch and replace it with pytest4-02.patch,
which is the upstream gh#hamcrest/PyHamcrest#124 fixing
compatibility with pytest 4+ officially. And of course, we
don't have to massacre test files anymore.
-------------------------------------------------------------------
Tue Nov 5 11:20:23 UTC 2019 - Matej Cepl <mcepl@suse.com>
- Run spec-cleaner
- Add pytest4.patch to make the testsuite actually really pass.
-------------------------------------------------------------------
Mon Nov 4 14:35:43 UTC 2019 - Matej Cepl <mcepl@suse.com>
- Because of gh#hamcrest/PyHamcrest#123 we have to remove
tests/hamcrest_unit_test/core/is{_test,instanceof_test}.py to
make the test suite passing.
Patch pytest4.patch has been removed, it was a step into dead
end.
-------------------------------------------------------------------
Fri Jul 19 10:22:31 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com>
- Restrict pytest to 3.x as the newer does not work with release.
In upstream git this was fixed by quite few commits so lets
just wait for the release
-------------------------------------------------------------------
Wed Jul 3 08:35:33 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com>
- Add patch to fix build with new pytest:
* pytest4.patch
-------------------------------------------------------------------
Wed Oct 17 07:51:50 UTC 2018 - Tomáš Chvátal <tchvatal@suse.com>
- Provide and obsolete hamcrest
- Add patch from python-hamcrest which we now obsolete:
* 0001-Add-boolean-matchers.patch
-------------------------------------------------------------------
Thu Oct 11 08:13:20 UTC 2018 - Tomáš Chvátal <tchvatal@suse.com>
- Sort the deps with spec-cleaner
-------------------------------------------------------------------
Sat Oct 6 09:27:07 UTC 2018 - ecsos@opensuse.org
- initial version 1.9.0

67
python-PyHamcrest.spec Normal file
View File

@ -0,0 +1,67 @@
#
# spec file for package python-PyHamcrest
#
# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define skip_python2 1
%{?sle15_python_module_pythons}
Name: python-PyHamcrest
Version: 2.0.3
Release: 0
Summary: Hamcrest framework for matcher objects
License: BSD-3-Clause
URL: https://github.com/hamcrest/PyHamcrest
# PyPi is missing tests
#Source: https://files.pythonhosted.org/packages/source/P/PyHamcrest/PyHamcrest-%%{version}.tar.gz
Source: https://github.com/hamcrest/PyHamcrest/archive/V%{version}.tar.gz
Patch0: 0001-Add-boolean-matchers.patch
BuildRequires: %{python_module hypothesis >= 1.11}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Provides: python-hamcrest = %{version}
Obsoletes: python-hamcrest < %{version}
BuildArch: noarch
%python_subpackages
%description
Hamcrest framework for matcher objects.
PyHamcrest is a framework for writing matcher objects,
allowing you to declaratively define “match” rules.
%prep
%setup -q -n PyHamcrest-%{version}
%autopatch -p1
%build
%python_build
%install
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}/hamcrest
%check
%pytest
%files %{python_files}
%license LICENSE.txt
%doc README.rst
%{python_sitelib}/hamcrest
%{python_sitelib}/PyHamcrest-%{version}-py*.egg-info/
%changelog