[arch-commits] Commit in python-cmd2/repos/community-any (3 files)
Felix Yan
felixonmars at archlinux.org
Sun Jul 9 17:06:47 UTC 2017
Date: Sunday, July 9, 2017 @ 17:06:47
Author: felixonmars
Revision: 243442
archrelease: copy trunk to community-any
Added:
python-cmd2/repos/community-any/PKGBUILD
(from rev 243441, python-cmd2/trunk/PKGBUILD)
python-cmd2/repos/community-any/fix-test.patch
(from rev 243441, python-cmd2/trunk/fix-test.patch)
Deleted:
python-cmd2/repos/community-any/PKGBUILD
----------------+
PKGBUILD | 111 +++++++++++++++++++++++++++----------------------------
fix-test.patch | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 158 insertions(+), 55 deletions(-)
Deleted: PKGBUILD
===================================================================
--- PKGBUILD 2017-07-09 17:06:24 UTC (rev 243441)
+++ PKGBUILD 2017-07-09 17:06:47 UTC (rev 243442)
@@ -1,55 +0,0 @@
-# $Id$
-# Maintainer: Felix Yan <felixonmars at archlinux.org>
-# Contributor: Daniel Wallace <danielwallace at gtmanfred dot com>
-
-pkgbase=python-cmd2
-pkgname=(python-cmd2 python2-cmd2)
-pkgver=0.7.4
-pkgrel=1
-pkgdesc="Extra features for standard library's cmd module"
-arch=('any')
-url="https://github.com/python-cmd2/cmd2"
-license=('MIT')
-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')
-
-prepare() {
- cp -a cmd2-$pkgver{,-py2}
-}
-
-build() {
- cd "$srcdir"/cmd2-$pkgver
- python setup.py build
-
- cd "$srcdir"/cmd2-$pkgver-py2
- python2 setup.py build
-}
-
-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'"
-
- cd "$srcdir"/cmd2-$pkgver-py2
- python2 setup.py pytest --addopts "-k 'not test_path_completion_user_expansion'"
-}
-
-package_python-cmd2() {
- depends=('python-pyparsing' 'python-pyperclip')
-
- cd "$srcdir"/cmd2-$pkgver
- python setup.py install --root="$pkgdir" --optimize=1
-}
-
-package_python2-cmd2() {
- depends=('python2-pyparsing' 'python2-pyperclip')
-
- cd "$srcdir"/cmd2-$pkgver-py2
- python2 setup.py install --root="$pkgdir" --optimize=1
-}
-
-# vim:set ts=2 sw=2 et:
Copied: python-cmd2/repos/community-any/PKGBUILD (from rev 243441, python-cmd2/trunk/PKGBUILD)
===================================================================
--- PKGBUILD (rev 0)
+++ PKGBUILD 2017-07-09 17:06:47 UTC (rev 243442)
@@ -0,0 +1,56 @@
+# $Id$
+# Maintainer: Felix Yan <felixonmars at archlinux.org>
+# Contributor: Daniel Wallace <danielwallace at gtmanfred dot com>
+
+pkgbase=python-cmd2
+pkgname=(python-cmd2 python2-cmd2)
+pkgver=0.7.5
+pkgrel=1
+pkgdesc="Extra features for standard library's cmd module"
+arch=('any')
+url="https://github.com/python-cmd2/cmd2"
+license=('MIT')
+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"
+ fix-test.patch)
+sha512sums=('27f8d4076d6abcafef5e7a79049ab281e4bd76fa22ee83ea0c390af646cd8af03d93b4a05ab27eddb3974955fe5eb4f3fbff531b8903e2fa49fbd7d370603da9'
+ '4d9b2bd0125540935353d88d29ea5ffa78065cdf45d8f35b38ddf3eedd8c6193d518813aeccddb9261344c49b79fcdada39cb4de2f439a5e5faa2134147bd928')
+
+prepare() {
+ (cd cmd2-$pkgver; patch -p1 -i ../fix-test.patch)
+ cp -a cmd2-$pkgver{,-py2}
+}
+
+build() {
+ cd "$srcdir"/cmd2-$pkgver
+ python setup.py build
+
+ cd "$srcdir"/cmd2-$pkgver-py2
+ python2 setup.py build
+}
+
+check() {
+ cd "$srcdir"/cmd2-$pkgver
+ python setup.py pytest
+
+ cd "$srcdir"/cmd2-$pkgver-py2
+ python2 setup.py pytest
+}
+
+package_python-cmd2() {
+ depends=('python-pyparsing' 'python-pyperclip')
+
+ cd "$srcdir"/cmd2-$pkgver
+ python setup.py install --root="$pkgdir" --optimize=1
+}
+
+package_python2-cmd2() {
+ depends=('python2-pyparsing' 'python2-pyperclip')
+
+ cd "$srcdir"/cmd2-$pkgver-py2
+ python2 setup.py install --root="$pkgdir" --optimize=1
+}
+
+# vim:set ts=2 sw=2 et:
Copied: python-cmd2/repos/community-any/fix-test.patch (from rev 243441, python-cmd2/trunk/fix-test.patch)
===================================================================
--- fix-test.patch (rev 0)
+++ fix-test.patch 2017-07-09 17:06:47 UTC (rev 243442)
@@ -0,0 +1,102 @@
+commit 87e04d73046e910b639aaec462b4b77a1735f404
+Author: Felix Yan <felixonmars at archlinux.org>
+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')
+- os.system = m
++ monkeypatch.setattr("os.system", m)
+
+ # Run help command just so we have a command in history
+ run_cmd(base_app, 'help')
+@@ -693,13 +693,13 @@ def test_edit_number(base_app):
+ # We have an editor, so should expect a system call
+ m.assert_called_once()
+
+-def test_edit_blank(base_app):
++def test_edit_blank(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')
+- os.system = m
++ monkeypatch.setattr("os.system", m)
+
+ # Run help command just so we have a command in history
+ run_cmd(base_app, 'help')
+@@ -1222,7 +1222,7 @@ def abbrev_app():
+ app.stdout = StdOut()
+ return app
+
+-def test_exclude_from_history(abbrev_app):
++def test_exclude_from_history(abbrev_app, monkeypatch):
+ # Run all variants of run
+ run_cmd(abbrev_app, 'run')
+ run_cmd(abbrev_app, 'ru')
+@@ -1230,7 +1230,7 @@ def test_exclude_from_history(abbrev_app):
+
+ # 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)
+
+ # Run all variants of edit
+ run_cmd(abbrev_app, 'edit')
More information about the arch-commits
mailing list