[arch-commits] Commit in python-cmd2/trunk (PKGBUILD fix-test.patch)
Date: Saturday, August 12, 2017 @ 06:44:17 Author: felixonmars Revision: 249946 upgpkg: python-cmd2 0.7.6-1 Modified: python-cmd2/trunk/PKGBUILD Deleted: python-cmd2/trunk/fix-test.patch + PKGBUILD | 13 ++- fix-test.patch | 102 --- 2 files changed, 5 insertions(+), 110 deletions(-) Modified: PKGBUILD === --- PKGBUILD2017-08-12 06:01:01 UTC (rev 249945) +++ PKGBUILD2017-08-12 06:44:17 UTC (rev 249946) @@ -4,7 +4,7 @@ pkgbase=python-cmd2 pkgname=(python-cmd2 python2-cmd2) -pkgver=0.7.5 +pkgver=0.7.6 pkgrel=1 pkgdesc="Extra features for standard library's cmd module" arch=('any') @@ -11,15 +11,12 @@ url="https://github.com/python-cmd2/cmd2; license=('MIT') makedepends=('python-setuptools' 'python2-setuptools' 'python-pyparsing' 'python2-pyparsing' - 'python-pyperclip' 'python2-pyperclip') + 'python-pyperclip' 'python2-pyperclip' 'python2-subprocess32') checkdepends=('python-pytest-runner' 'python2-pytest-runner' 'python-mock' 'python2-mock' 'vi') -source=("$pkgbase-$pkgver.tar.gz::https://github.com/python-cmd2/cmd2/archive/$pkgver.tar.gz; -fix-test.patch) -sha512sums=('27f8d4076d6abcafef5e7a79049ab281e4bd76fa22ee83ea0c390af646cd8af03d93b4a05ab27eddb3974955fe5eb4f3fbff531b8903e2fa49fbd7d370603da9' - '4d9b2bd0125540935353d88d29ea5ffa78065cdf45d8f35b38ddf3eedd8c6193d518813aeccddb9261344c49b79fcdada39cb4de2f439a5e5faa2134147bd928') +source=("$pkgbase-$pkgver.tar.gz::https://github.com/python-cmd2/cmd2/archive/$pkgver.tar.gz;) +sha512sums=('05e988deb762725d17ce7b109e2b5d9d6f0b9f40af57fe428e75529c9d1f171d2677f2ab3586e418b20184e06bb5adab1dc93ec40f35014917d5871e6d88cdde') prepare() { - (cd cmd2-$pkgver; patch -p1 -i ../fix-test.patch) cp -a cmd2-$pkgver{,-py2} } @@ -47,7 +44,7 @@ } package_python2-cmd2() { - depends=('python2-pyparsing' 'python2-pyperclip') + depends=('python2-pyparsing' 'python2-pyperclip' 'python2-subprocess32') cd "$srcdir"/cmd2-$pkgver-py2 python2 setup.py install --root="$pkgdir" --optimize=1 Deleted: fix-test.patch === --- fix-test.patch 2017-08-12 06:01:01 UTC (rev 249945) +++ fix-test.patch 2017-08-12 06:44:17 UTC (rev 249946) @@ -1,102 +0,0 @@ -commit 87e04d73046e910b639aaec462b4b77a1735f404 -Author: Felix Yan-Date: Mon Jul 10 00:29:42 2017 +0800 - -Use monkeypatch to ensure os.system is restored - -Without this patch, running tests like test_edit_number before -test_default_to_shell_good in the same process will trigger -this error: - -``` -___ test_default_to_shell_good - -capsys = <_pytest.capture.CaptureFixture object at 0x7f7e90103898> - -def test_default_to_shell_good(capsys): -app = cmd2.Cmd() -app.default_to_shell = True -line = 'ls' -statement = app.parser_manager.parsed(line) -retval = app._default(statement) -assert not retval -out, err = capsys.readouterr() -> assert out == '' -E AssertionError: assert '*** Unknown syntax: ls \n' == '' -E - *** Unknown syntax: ls - -tests/test_cmd2.py:840: AssertionError -``` - -Using monkeypatch fixture to restore os.system fixes the problem here. - -diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py -index 1deff47..0e25529 100644 a/tests/test_cmd2.py -+++ b/tests/test_cmd2.py -@@ -661,13 +661,13 @@ def test_edit_no_editor(base_app, capsys): - expected = _expected_no_editor_error() - assert normalize(str(err)) == expected - --def test_edit_file(base_app, request): -+def test_edit_file(base_app, request, monkeypatch): - # Set a fake editor just to make sure we have one. We aren't really going to call it due to the mock - base_app.editor = 'fooedit' - - # Mock out the os.system call so we don't actually open an editor - m = mock.MagicMock(name='system') --os.system = m -+monkeypatch.setattr("os.system", m) - - test_dir = os.path.dirname(request.module.__file__) - filename = os.path.join(test_dir, 'script.txt') -@@ -677,13 +677,13 @@ def test_edit_file(base_app, request): - # We think we have an editor, so should expect a system call - m.assert_called_once_with('{} {}'.format(base_app.editor, filename)) - --def test_edit_number(base_app): -+def test_edit_number(base_app, monkeypatch): - # Set a fake editor just to make sure we have one. We aren't really going to call it due to the mock - base_app.editor = 'fooedit' - - # Mock out the os.system call so we don't actually open an editor - m =
[arch-commits] Commit in python-cmd2/trunk (PKGBUILD fix-test.patch)
Date: Sunday, July 9, 2017 @ 17:06:24 Author: felixonmars Revision: 243441 upgpkg: python-cmd2 0.7.5-1 Added: python-cmd2/trunk/fix-test.patch Modified: python-cmd2/trunk/PKGBUILD + PKGBUILD | 15 fix-test.patch | 102 +++ 2 files changed, 110 insertions(+), 7 deletions(-) Modified: PKGBUILD === --- PKGBUILD2017-07-09 17:00:34 UTC (rev 243440) +++ PKGBUILD2017-07-09 17:06:24 UTC (rev 243441) @@ -4,7 +4,7 @@ pkgbase=python-cmd2 pkgname=(python-cmd2 python2-cmd2) -pkgver=0.7.4 +pkgver=0.7.5 pkgrel=1 pkgdesc="Extra features for standard library's cmd module" arch=('any') @@ -13,10 +13,13 @@ makedepends=('python-setuptools' 'python2-setuptools' 'python-pyparsing' 'python2-pyparsing' 'python-pyperclip' 'python2-pyperclip') checkdepends=('python-pytest-runner' 'python2-pytest-runner' 'python-mock' 'python2-mock' 'vi') -source=("$pkgbase-$pkgver.tar.gz::https://github.com/python-cmd2/cmd2/archive/$pkgver.tar.gz;) -sha512sums=('9d2d84a773a6ee534336b4044e32521def400b81a7e5ac22dbc9b18ac4088d2adff34139965b382fb35d278c0f1dce83f43219a79c5fb8a642aafbfebe6dea83') +source=("$pkgbase-$pkgver.tar.gz::https://github.com/python-cmd2/cmd2/archive/$pkgver.tar.gz; +fix-test.patch) +sha512sums=('27f8d4076d6abcafef5e7a79049ab281e4bd76fa22ee83ea0c390af646cd8af03d93b4a05ab27eddb3974955fe5eb4f3fbff531b8903e2fa49fbd7d370603da9' + '4d9b2bd0125540935353d88d29ea5ffa78065cdf45d8f35b38ddf3eedd8c6193d518813aeccddb9261344c49b79fcdada39cb4de2f439a5e5faa2134147bd928') prepare() { + (cd cmd2-$pkgver; patch -p1 -i ../fix-test.patch) cp -a cmd2-$pkgver{,-py2} } @@ -29,13 +32,11 @@ } check() { - # https://github.com/python-cmd2/cmd2/issues/171 - cd "$srcdir"/cmd2-$pkgver - python setup.py pytest --addopts "-k 'not test_path_completion_user_expansion'" + python setup.py pytest cd "$srcdir"/cmd2-$pkgver-py2 - python2 setup.py pytest --addopts "-k 'not test_path_completion_user_expansion'" + python2 setup.py pytest } package_python-cmd2() { Added: fix-test.patch === --- fix-test.patch (rev 0) +++ fix-test.patch 2017-07-09 17:06:24 UTC (rev 243441) @@ -0,0 +1,102 @@ +commit 87e04d73046e910b639aaec462b4b77a1735f404 +Author: Felix Yan+Date: Mon Jul 10 00:29:42 2017 +0800 + +Use monkeypatch to ensure os.system is restored + +Without this patch, running tests like test_edit_number before +test_default_to_shell_good in the same process will trigger +this error: + +``` +___ test_default_to_shell_good + +capsys = <_pytest.capture.CaptureFixture object at 0x7f7e90103898> + +def test_default_to_shell_good(capsys): +app = cmd2.Cmd() +app.default_to_shell = True +line = 'ls' +statement = app.parser_manager.parsed(line) +retval = app._default(statement) +assert not retval +out, err = capsys.readouterr() +> assert out == '' +E AssertionError: assert '*** Unknown syntax: ls \n' == '' +E - *** Unknown syntax: ls + +tests/test_cmd2.py:840: AssertionError +``` + +Using monkeypatch fixture to restore os.system fixes the problem here. + +diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py +index 1deff47..0e25529 100644 +--- a/tests/test_cmd2.py b/tests/test_cmd2.py +@@ -661,13 +661,13 @@ def test_edit_no_editor(base_app, capsys): + expected = _expected_no_editor_error() + assert normalize(str(err)) == expected + +-def test_edit_file(base_app, request): ++def test_edit_file(base_app, request, monkeypatch): + # Set a fake editor just to make sure we have one. We aren't really going to call it due to the mock + base_app.editor = 'fooedit' + + # Mock out the os.system call so we don't actually open an editor + m = mock.MagicMock(name='system') +-os.system = m ++monkeypatch.setattr("os.system", m) + + test_dir = os.path.dirname(request.module.__file__) + filename = os.path.join(test_dir, 'script.txt') +@@ -677,13 +677,13 @@ def test_edit_file(base_app, request): + # We think we have an editor, so should expect a system call + m.assert_called_once_with('{} {}'.format(base_app.editor, filename)) + +-def test_edit_number(base_app): ++def test_edit_number(base_app, monkeypatch): + # Set a fake editor just to make sure we have one. We aren't really going to call it due to the mock + base_app.editor = 'fooedit' + + # Mock out the os.system call so we don't actually open an editor + m = mock.MagicMock(name='system') +-