forked from pool/python-re-assert
Accepting request 844697 from home:jayvdb:branches:devel:languages:python
new build dep of aiohttp OBS-URL: https://build.opensuse.org/request/show/844697 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-re-assert?expand=0&rev=1
This commit is contained in:
23
.gitattributes
vendored
Normal file
23
.gitattributes
vendored
Normal 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
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.osc
|
19
LICENSE
Normal file
19
LICENSE
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
Copyright (c) 2019 Anthony Sottile
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
10
python-re-assert.changes
Normal file
10
python-re-assert.changes
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Oct 29 00:58:23 UTC 2020 - John Vandenberg <jayvdb@gmail.com>
|
||||||
|
|
||||||
|
- Add test suite and LICENSE from upstream
|
||||||
|
- Activate test suite
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Sat Feb 15 03:48:46 AM UTC 2020 - John Vandenberg <jayvdb@gmail.com>
|
||||||
|
|
||||||
|
- Initial spec for v1.0.0
|
62
python-re-assert.spec
Normal file
62
python-re-assert.spec
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
#
|
||||||
|
# spec file for package python-re-assert
|
||||||
|
#
|
||||||
|
# Copyright (c) 2020 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-%{**}}
|
||||||
|
Name: python-re-assert
|
||||||
|
Version: 1.0.0
|
||||||
|
Release: 0
|
||||||
|
Summary: Show Python regex match assertion failures
|
||||||
|
License: MIT
|
||||||
|
Group: Development/Languages/Python
|
||||||
|
URL: https://github.com/asottile/re-assert
|
||||||
|
Source: https://files.pythonhosted.org/packages/source/r/re_assert/re_assert-%{version}.tar.gz
|
||||||
|
Source1: https://raw.githubusercontent.com/asottile/re-assert/master/tests/re_assert_test.py
|
||||||
|
Source2: https://raw.githubusercontent.com/asottile/re-assert/master/LICENSE
|
||||||
|
BuildRequires: %{python_module setuptools}
|
||||||
|
BuildRequires: fdupes
|
||||||
|
BuildRequires: python-rpm-macros
|
||||||
|
Requires: python-regex
|
||||||
|
BuildArch: noarch
|
||||||
|
# SECTION test requirements
|
||||||
|
BuildRequires: %{python_module pytest}
|
||||||
|
BuildRequires: %{python_module regex}
|
||||||
|
# /SECTION
|
||||||
|
%python_subpackages
|
||||||
|
|
||||||
|
%description
|
||||||
|
Show where your regex match assertion failed.
|
||||||
|
|
||||||
|
%prep
|
||||||
|
%setup -q -n re_assert-%{version}
|
||||||
|
cp %{SOURCE1} %{SOURCE2} .
|
||||||
|
|
||||||
|
%build
|
||||||
|
%python_build
|
||||||
|
|
||||||
|
%install
|
||||||
|
%python_install
|
||||||
|
%python_expand %fdupes %{buildroot}%{$python_sitelib}
|
||||||
|
|
||||||
|
%check
|
||||||
|
%pytest
|
||||||
|
|
||||||
|
%files %{python_files}
|
||||||
|
%license LICENSE
|
||||||
|
%{python_sitelib}/*
|
||||||
|
|
||||||
|
%changelog
|
3
re_assert-1.0.0.tar.gz
Normal file
3
re_assert-1.0.0.tar.gz
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:bc506382b1b9e77df7a6adfdd2a7d58871f7231113de0417e498dda61117c42d
|
||||||
|
size 3888
|
116
re_assert_test.py
Normal file
116
re_assert_test.py
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
import re
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from re_assert import Matches
|
||||||
|
|
||||||
|
|
||||||
|
def test_typeerror_equality_different_type():
|
||||||
|
with pytest.raises(TypeError):
|
||||||
|
Matches('foo') == b'foo'
|
||||||
|
|
||||||
|
|
||||||
|
def test_matches_repr_plain():
|
||||||
|
assert repr(Matches('^foo')) == "Matches('^foo')"
|
||||||
|
|
||||||
|
|
||||||
|
def test_matches_repr_with_flags():
|
||||||
|
ret = repr(Matches('^foo', re.I))
|
||||||
|
assert ret == "Matches('^foo', flags=regex.I | regex.V0)"
|
||||||
|
|
||||||
|
|
||||||
|
def test_repr_with_failure():
|
||||||
|
obj = Matches('^foo')
|
||||||
|
assert obj != 'fa'
|
||||||
|
assert repr(obj) == (
|
||||||
|
"Matches('^foo')\n"
|
||||||
|
' # regex failed to match at:\n'
|
||||||
|
' #\n'
|
||||||
|
' #> fa\n'
|
||||||
|
' # ^'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_assert_success():
|
||||||
|
obj = Matches('foo')
|
||||||
|
assert obj == 'food'
|
||||||
|
obj.assert_matches('food')
|
||||||
|
|
||||||
|
|
||||||
|
def test_fail_at_beginning():
|
||||||
|
with pytest.raises(AssertionError) as excinfo:
|
||||||
|
Matches('foo').assert_matches('bar')
|
||||||
|
msg, = excinfo.value.args
|
||||||
|
assert msg == (
|
||||||
|
' regex failed to match at:\n'
|
||||||
|
'\n'
|
||||||
|
'> bar\n'
|
||||||
|
' ^'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_fail_at_end_of_line():
|
||||||
|
with pytest.raises(AssertionError) as excinfo:
|
||||||
|
Matches('foo').assert_matches('fo')
|
||||||
|
msg, = excinfo.value.args
|
||||||
|
assert msg == (
|
||||||
|
' regex failed to match at:\n'
|
||||||
|
'\n'
|
||||||
|
'> fo\n'
|
||||||
|
' ^'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_fail_multiple_lines():
|
||||||
|
with pytest.raises(AssertionError) as excinfo:
|
||||||
|
Matches('foo.bar', re.DOTALL).assert_matches('foo\nbr')
|
||||||
|
msg, = excinfo.value.args
|
||||||
|
assert msg == (
|
||||||
|
' regex failed to match at:\n'
|
||||||
|
'\n'
|
||||||
|
'> foo\n'
|
||||||
|
'> br\n'
|
||||||
|
' ^'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_fail_end_of_line_with_newline():
|
||||||
|
with pytest.raises(AssertionError) as excinfo:
|
||||||
|
Matches('foo.bar', re.DOTALL).assert_matches('foo\n')
|
||||||
|
msg, = excinfo.value.args
|
||||||
|
assert msg == (
|
||||||
|
' regex failed to match at:\n'
|
||||||
|
'\n'
|
||||||
|
'> foo\n'
|
||||||
|
'>\n'
|
||||||
|
' ^'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_fail_at_end_of_line_mismatching_newline():
|
||||||
|
with pytest.raises(AssertionError) as excinfo:
|
||||||
|
Matches('foo.', re.DOTALL).assert_matches('foo')
|
||||||
|
msg, = excinfo.value.args
|
||||||
|
assert msg == (
|
||||||
|
' regex failed to match at:\n'
|
||||||
|
'\n'
|
||||||
|
'> foo\n'
|
||||||
|
' ^'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_match_with_tabs():
|
||||||
|
with pytest.raises(AssertionError) as excinfo:
|
||||||
|
Matches('f.o.o').assert_matches('f\to\tx\n')
|
||||||
|
msg, = excinfo.value.args
|
||||||
|
assert msg == (
|
||||||
|
' regex failed to match at:\n'
|
||||||
|
'\n'
|
||||||
|
'> f\to\tx\n'
|
||||||
|
' \t \t^'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_from_pattern():
|
||||||
|
pattern = re.compile('^foo', flags=re.I)
|
||||||
|
assert Matches.from_pattern(pattern) == 'FOO'
|
Reference in New Issue
Block a user