%global _empty_manifest_terminate_build 0 Name: python-pytruth Version: 1.1.0 Release: 1 Summary: Provides unittest assertions in a fluent style. License: Apache 2.0 URL: https://github.com/google/pytruth Source0: https://mirrors.nju.edu.cn/pypi/web/packages/24/61/2fc9a9cc1144c9123c053741cbf3f19e9213cdf658fef5f993b025e44c29/pytruth-1.1.0.tar.gz BuildArch: noarch Requires: python3-six Requires: python3-wheel %description # PyTruth: Truth in Python [![Development Status][development-shield]][development-link] [![Build Status][travis-shield]][travis-link] [![PyPI Version][pypi-shield]][pypi-link] [![Python Versions][pyversions-shield]][pyversions-link] Provides unittest assertions in a fluent style. Translated from the Java implementation, [google/truth](https://github.com/google/truth). ## License PyTruth is licensed under the [Apache 2.0 license](LICENSE). ## Disclaimer PyTruth is not an official Google product. ## Contributing Please see the [guidelines for contributing](CONTRIBUTING.md) before creating pull requests. ## Support PyTruth is not an actively maintained project. No support is provided. It is shared with the community to bring an expressive, consistent assertion style to projects that may be using a combination of [unittest](https://docs.python.org/3/library/unittest.html), [abseil](https://github.com/abseil/abseil-py), [googletest](https://github.com/google/googletest), [mox](https://pypi.python.org/pypi/mox), and [mock](https://docs.python.org/3/library/unittest.mock.html)—especially to people familiar with [Java Truth](https://github.com/google/truth). User group: [pytruth-users@googlegroups.com](https://groups.google.com/d/forum/pytruth-users) ### Installing PyTruth can be installed using [pip](https://pypi.org/project/pip/): ```bash pip install pytruth ``` ## Overview Import the `truth` module and alias the `AssertThat()` method to begin asserting things: ```python from truth.truth import AssertThat ``` Then, instead of writing ```python self.assertEqual(a, b) self.assertTrue(c) self.assertIn(a, d) self.assertTrue(a in d and b in d) self.assertTrue(a in d or b in d or c in d) with self.assertRaises(Error): Explode() ``` one would write ```python AssertThat(a).IsEqualTo(b) AssertThat(c).IsTrue() AssertThat(d).Contains(a) AssertThat(d).ContainsAllOf(a, b) AssertThat(d).ContainsAnyOf(a, b, c) with AssertThat(Error).IsRaised(): Explode() ``` Tests should be easier to read and write, and flow more clearly. ## Limitations unittest assertions accept a `msg` parameter to display if the assertion fails. PyTruth has no such mechanism, though its failure messages tend to be more informative. The type of the subject under test (the parameter passed to `AssertThat()`) will not be known until runtime, unlike Java where the type is known at compile time. IDEs may not correctly autocomplete available predicates on an asserted subject. In Python 2, `None` compares less than every other thing, except `None` itself. `None` is less than `nan`, and it is less than negative infinity. Therefore, use caution when a function might return `None`. The assertion `AssertThat(Func()).IsLessThan(0)` succeeds whether `Func()` returns a negative number or `None`. Instead, first check the `None`-ness of the return value with `IsNone()` or `IsNotNone()` before performing an inequality assertion. In Python 3, `None` is no longer comparable using `<` `>` `<=` `>=`. PyTruth detects the version of the Python interpreter and compares or fails appropriately, rather than allowing Python 3's `TypeError` to bubble up. If the iterator over a shared value (either expected or actual) changes that value or its underlying elements, the behavior is undefined: all, none, or some of the assertions may succeed or fail, arbitrarily. This library is threadsafe; you may execute multiple assertions in parallel. ## Conversion Recipes ### General %package -n python3-pytruth Summary: Provides unittest assertions in a fluent style. Provides: python-pytruth BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-pytruth # PyTruth: Truth in Python [![Development Status][development-shield]][development-link] [![Build Status][travis-shield]][travis-link] [![PyPI Version][pypi-shield]][pypi-link] [![Python Versions][pyversions-shield]][pyversions-link] Provides unittest assertions in a fluent style. Translated from the Java implementation, [google/truth](https://github.com/google/truth). ## License PyTruth is licensed under the [Apache 2.0 license](LICENSE). ## Disclaimer PyTruth is not an official Google product. ## Contributing Please see the [guidelines for contributing](CONTRIBUTING.md) before creating pull requests. ## Support PyTruth is not an actively maintained project. No support is provided. It is shared with the community to bring an expressive, consistent assertion style to projects that may be using a combination of [unittest](https://docs.python.org/3/library/unittest.html), [abseil](https://github.com/abseil/abseil-py), [googletest](https://github.com/google/googletest), [mox](https://pypi.python.org/pypi/mox), and [mock](https://docs.python.org/3/library/unittest.mock.html)—especially to people familiar with [Java Truth](https://github.com/google/truth). User group: [pytruth-users@googlegroups.com](https://groups.google.com/d/forum/pytruth-users) ### Installing PyTruth can be installed using [pip](https://pypi.org/project/pip/): ```bash pip install pytruth ``` ## Overview Import the `truth` module and alias the `AssertThat()` method to begin asserting things: ```python from truth.truth import AssertThat ``` Then, instead of writing ```python self.assertEqual(a, b) self.assertTrue(c) self.assertIn(a, d) self.assertTrue(a in d and b in d) self.assertTrue(a in d or b in d or c in d) with self.assertRaises(Error): Explode() ``` one would write ```python AssertThat(a).IsEqualTo(b) AssertThat(c).IsTrue() AssertThat(d).Contains(a) AssertThat(d).ContainsAllOf(a, b) AssertThat(d).ContainsAnyOf(a, b, c) with AssertThat(Error).IsRaised(): Explode() ``` Tests should be easier to read and write, and flow more clearly. ## Limitations unittest assertions accept a `msg` parameter to display if the assertion fails. PyTruth has no such mechanism, though its failure messages tend to be more informative. The type of the subject under test (the parameter passed to `AssertThat()`) will not be known until runtime, unlike Java where the type is known at compile time. IDEs may not correctly autocomplete available predicates on an asserted subject. In Python 2, `None` compares less than every other thing, except `None` itself. `None` is less than `nan`, and it is less than negative infinity. Therefore, use caution when a function might return `None`. The assertion `AssertThat(Func()).IsLessThan(0)` succeeds whether `Func()` returns a negative number or `None`. Instead, first check the `None`-ness of the return value with `IsNone()` or `IsNotNone()` before performing an inequality assertion. In Python 3, `None` is no longer comparable using `<` `>` `<=` `>=`. PyTruth detects the version of the Python interpreter and compares or fails appropriately, rather than allowing Python 3's `TypeError` to bubble up. If the iterator over a shared value (either expected or actual) changes that value or its underlying elements, the behavior is undefined: all, none, or some of the assertions may succeed or fail, arbitrarily. This library is threadsafe; you may execute multiple assertions in parallel. ## Conversion Recipes ### General %package help Summary: Development documents and examples for pytruth Provides: python3-pytruth-doc %description help # PyTruth: Truth in Python [![Development Status][development-shield]][development-link] [![Build Status][travis-shield]][travis-link] [![PyPI Version][pypi-shield]][pypi-link] [![Python Versions][pyversions-shield]][pyversions-link] Provides unittest assertions in a fluent style. Translated from the Java implementation, [google/truth](https://github.com/google/truth). ## License PyTruth is licensed under the [Apache 2.0 license](LICENSE). ## Disclaimer PyTruth is not an official Google product. ## Contributing Please see the [guidelines for contributing](CONTRIBUTING.md) before creating pull requests. ## Support PyTruth is not an actively maintained project. No support is provided. It is shared with the community to bring an expressive, consistent assertion style to projects that may be using a combination of [unittest](https://docs.python.org/3/library/unittest.html), [abseil](https://github.com/abseil/abseil-py), [googletest](https://github.com/google/googletest), [mox](https://pypi.python.org/pypi/mox), and [mock](https://docs.python.org/3/library/unittest.mock.html)—especially to people familiar with [Java Truth](https://github.com/google/truth). User group: [pytruth-users@googlegroups.com](https://groups.google.com/d/forum/pytruth-users) ### Installing PyTruth can be installed using [pip](https://pypi.org/project/pip/): ```bash pip install pytruth ``` ## Overview Import the `truth` module and alias the `AssertThat()` method to begin asserting things: ```python from truth.truth import AssertThat ``` Then, instead of writing ```python self.assertEqual(a, b) self.assertTrue(c) self.assertIn(a, d) self.assertTrue(a in d and b in d) self.assertTrue(a in d or b in d or c in d) with self.assertRaises(Error): Explode() ``` one would write ```python AssertThat(a).IsEqualTo(b) AssertThat(c).IsTrue() AssertThat(d).Contains(a) AssertThat(d).ContainsAllOf(a, b) AssertThat(d).ContainsAnyOf(a, b, c) with AssertThat(Error).IsRaised(): Explode() ``` Tests should be easier to read and write, and flow more clearly. ## Limitations unittest assertions accept a `msg` parameter to display if the assertion fails. PyTruth has no such mechanism, though its failure messages tend to be more informative. The type of the subject under test (the parameter passed to `AssertThat()`) will not be known until runtime, unlike Java where the type is known at compile time. IDEs may not correctly autocomplete available predicates on an asserted subject. In Python 2, `None` compares less than every other thing, except `None` itself. `None` is less than `nan`, and it is less than negative infinity. Therefore, use caution when a function might return `None`. The assertion `AssertThat(Func()).IsLessThan(0)` succeeds whether `Func()` returns a negative number or `None`. Instead, first check the `None`-ness of the return value with `IsNone()` or `IsNotNone()` before performing an inequality assertion. In Python 3, `None` is no longer comparable using `<` `>` `<=` `>=`. PyTruth detects the version of the Python interpreter and compares or fails appropriately, rather than allowing Python 3's `TypeError` to bubble up. If the iterator over a shared value (either expected or actual) changes that value or its underlying elements, the behavior is undefined: all, none, or some of the assertions may succeed or fail, arbitrarily. This library is threadsafe; you may execute multiple assertions in parallel. ## Conversion Recipes ### General %prep %autosetup -n pytruth-1.1.0 %build %py3_build %install %py3_install install -d -m755 %{buildroot}/%{_pkgdocdir} if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} if [ -d usr/lib ]; then find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/lib64 ]; then find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/bin ]; then find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/sbin ]; then find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst fi touch doclist.lst if [ -d usr/share/man ]; then find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst fi popd mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %files -n python3-pytruth -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Tue Apr 25 2023 Python_Bot - 1.1.0-1 - Package Spec generated