summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2023-05-10 07:42:05 +0000
committerCoprDistGit <infra@openeuler.org>2023-05-10 07:42:05 +0000
commit2c9df1e0495541e419e83c125f89f09aef70a265 (patch)
tree6384bba9d4454d4d5ec13f18a18c77b377c77bdb
parentdcc62fe97f8f667360f4810da344b8dbcd9e928b (diff)
automatic import of python-re-assert
-rw-r--r--.gitignore1
-rw-r--r--python-re-assert.spec250
-rw-r--r--sources1
3 files changed, 252 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..10e8dc2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/re_assert-1.1.0.tar.gz
diff --git a/python-re-assert.spec b/python-re-assert.spec
new file mode 100644
index 0000000..d8bede7
--- /dev/null
+++ b/python-re-assert.spec
@@ -0,0 +1,250 @@
+%global _empty_manifest_terminate_build 0
+Name: python-re-assert
+Version: 1.1.0
+Release: 1
+Summary: show where your regex match assertion failed!
+License: MIT
+URL: https://github.com/asottile/re-assert
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/72/89/5801de335fa7a9cd9f402f66680b14be076d2084dd8244e3a3136a743262/re_assert-1.1.0.tar.gz
+BuildArch: noarch
+
+Requires: python3-regex
+
+%description
+show where your regex match assertion failed!
+## installation
+`pip install re-assert`
+## usage
+`re-assert` provides a helper class to make assertions of regexes simpler.
+### `re_assert.Matches(pattern: str, *args, **kwargs)`
+construct a `Matches` object.
+_note_: under the hood, `re-assert` uses the [`regex`] library for matching,
+any `*args` / `**kwargs` that `regex.compile` supports will work. in general,
+ the `regex` library is 100% compatible with the `re` library (and will even
+accept its flags, etc.)
+[`regex`]: https://pypi.org/project/regex/
+### `re_assert.Matches.from_pattern(pattern: Pattern[str]) -> Matches`
+construct a `Matches` object from an already-compiled regex.
+this is useful (for instance) if you're testing an existing compiled regex.
+```pycon
+>>> import re
+>>> reg = re.compile('foo')
+>>> Matches.from_pattern(reg) == 'fork'
+False
+>>> Matches.from_pattern(reg) == 'food'
+True
+```
+### `Matches.__eq__(other)` (`==`)
+the equality operator is overridden for use with assertion frameworks such
+as pytest
+```pycon
+>>> pat = Matches('foo')
+>>> pat == 'bar'
+False
+>>> pat == 'food'
+True
+```
+### `Matches.__repr__()` (`repr(...)`)
+a side-effect of an equality failure changes the `repr(...)` of a `Matches`
+object. this allows for useful pytest assertion messages:
+```pytest
+> assert Matches('foo') == 'fork'
+E AssertionError: assert Matches('foo'...ork\n # ^ == 'fork'
+E -Matches('foo')\n
+E - # regex failed to match at:\n
+E - #\n
+E - #> fork\n
+E - # ^
+E +'fork'
+```
+### `Matches.assert_matches(s: str)`
+if you're using some other test framework, this method is useful for producing
+a readable traceback
+```pycon
+>>> Matches('foo').assert_matches('food')
+>>> Matches('foo').assert_matches('fork')
+Traceback (most recent call last):
+ File "<stdin>", line 1, in <module>
+ File "/home/asottile/workspace/re-assert/re_assert.py", line 63, in assert_matches
+ assert self == s, self._fail
+AssertionError: regex failed to match at:
+> fork
+ ^
+```
+
+%package -n python3-re-assert
+Summary: show where your regex match assertion failed!
+Provides: python-re-assert
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-re-assert
+show where your regex match assertion failed!
+## installation
+`pip install re-assert`
+## usage
+`re-assert` provides a helper class to make assertions of regexes simpler.
+### `re_assert.Matches(pattern: str, *args, **kwargs)`
+construct a `Matches` object.
+_note_: under the hood, `re-assert` uses the [`regex`] library for matching,
+any `*args` / `**kwargs` that `regex.compile` supports will work. in general,
+ the `regex` library is 100% compatible with the `re` library (and will even
+accept its flags, etc.)
+[`regex`]: https://pypi.org/project/regex/
+### `re_assert.Matches.from_pattern(pattern: Pattern[str]) -> Matches`
+construct a `Matches` object from an already-compiled regex.
+this is useful (for instance) if you're testing an existing compiled regex.
+```pycon
+>>> import re
+>>> reg = re.compile('foo')
+>>> Matches.from_pattern(reg) == 'fork'
+False
+>>> Matches.from_pattern(reg) == 'food'
+True
+```
+### `Matches.__eq__(other)` (`==`)
+the equality operator is overridden for use with assertion frameworks such
+as pytest
+```pycon
+>>> pat = Matches('foo')
+>>> pat == 'bar'
+False
+>>> pat == 'food'
+True
+```
+### `Matches.__repr__()` (`repr(...)`)
+a side-effect of an equality failure changes the `repr(...)` of a `Matches`
+object. this allows for useful pytest assertion messages:
+```pytest
+> assert Matches('foo') == 'fork'
+E AssertionError: assert Matches('foo'...ork\n # ^ == 'fork'
+E -Matches('foo')\n
+E - # regex failed to match at:\n
+E - #\n
+E - #> fork\n
+E - # ^
+E +'fork'
+```
+### `Matches.assert_matches(s: str)`
+if you're using some other test framework, this method is useful for producing
+a readable traceback
+```pycon
+>>> Matches('foo').assert_matches('food')
+>>> Matches('foo').assert_matches('fork')
+Traceback (most recent call last):
+ File "<stdin>", line 1, in <module>
+ File "/home/asottile/workspace/re-assert/re_assert.py", line 63, in assert_matches
+ assert self == s, self._fail
+AssertionError: regex failed to match at:
+> fork
+ ^
+```
+
+%package help
+Summary: Development documents and examples for re-assert
+Provides: python3-re-assert-doc
+%description help
+show where your regex match assertion failed!
+## installation
+`pip install re-assert`
+## usage
+`re-assert` provides a helper class to make assertions of regexes simpler.
+### `re_assert.Matches(pattern: str, *args, **kwargs)`
+construct a `Matches` object.
+_note_: under the hood, `re-assert` uses the [`regex`] library for matching,
+any `*args` / `**kwargs` that `regex.compile` supports will work. in general,
+ the `regex` library is 100% compatible with the `re` library (and will even
+accept its flags, etc.)
+[`regex`]: https://pypi.org/project/regex/
+### `re_assert.Matches.from_pattern(pattern: Pattern[str]) -> Matches`
+construct a `Matches` object from an already-compiled regex.
+this is useful (for instance) if you're testing an existing compiled regex.
+```pycon
+>>> import re
+>>> reg = re.compile('foo')
+>>> Matches.from_pattern(reg) == 'fork'
+False
+>>> Matches.from_pattern(reg) == 'food'
+True
+```
+### `Matches.__eq__(other)` (`==`)
+the equality operator is overridden for use with assertion frameworks such
+as pytest
+```pycon
+>>> pat = Matches('foo')
+>>> pat == 'bar'
+False
+>>> pat == 'food'
+True
+```
+### `Matches.__repr__()` (`repr(...)`)
+a side-effect of an equality failure changes the `repr(...)` of a `Matches`
+object. this allows for useful pytest assertion messages:
+```pytest
+> assert Matches('foo') == 'fork'
+E AssertionError: assert Matches('foo'...ork\n # ^ == 'fork'
+E -Matches('foo')\n
+E - # regex failed to match at:\n
+E - #\n
+E - #> fork\n
+E - # ^
+E +'fork'
+```
+### `Matches.assert_matches(s: str)`
+if you're using some other test framework, this method is useful for producing
+a readable traceback
+```pycon
+>>> Matches('foo').assert_matches('food')
+>>> Matches('foo').assert_matches('fork')
+Traceback (most recent call last):
+ File "<stdin>", line 1, in <module>
+ File "/home/asottile/workspace/re-assert/re_assert.py", line 63, in assert_matches
+ assert self == s, self._fail
+AssertionError: regex failed to match at:
+> fork
+ ^
+```
+
+%prep
+%autosetup -n re-assert-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-re-assert -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Wed May 10 2023 Python_Bot <Python_Bot@openeuler.org> - 1.1.0-1
+- Package Spec generated
diff --git a/sources b/sources
new file mode 100644
index 0000000..7668597
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+c948ac9a95285ab2b8048408fb70c978 re_assert-1.1.0.tar.gz