[Python-modules-commits] [systemfixtures] 01/03: New upstream version 0.6.2
Free Ekanayaka
freee at moszumanska.debian.org
Thu Jan 5 21:58:04 UTC 2017
This is an automated email from the git hooks/post-receive script.
freee pushed a commit to branch master
in repository systemfixtures.
commit a31da5bc54ff1d981114f12b885c69dff93cdddc
Author: Free Ekanayaka <freee at debian.org>
Date: Thu Jan 5 21:36:57 2017 +0000
New upstream version 0.6.2
---
.coveragerc.py27 => .coveragerc.py2 | 0
.coveragerc.py35 => .coveragerc.py3 | 2 +-
.testr.conf | 4 ---
AUTHORS | 1 -
ChangeLog | 9 +++++
HACKING.rst | 56 +++++++++++++++++++++++++++++++
MANIFEST.in | 1 +
Makefile | 44 +++++++++++++++++++++++++
PKG-INFO | 12 ++++---
README.rst | 10 ++++--
{docs => doc}/Makefile | 2 +-
{docs => doc}/_static/.placeholder | 0
{docs => doc}/conf.py | 0
{docs => doc}/index.rst | 0
requirements.txt | 1 +
setup.cfg | 7 ++--
systemfixtures.egg-info/PKG-INFO | 12 ++++---
systemfixtures.egg-info/SOURCES.txt | 16 ++++-----
systemfixtures.egg-info/pbr.json | 2 +-
systemfixtures.egg-info/requires.txt | 6 ++--
systemfixtures/executable.py | 58 +++++++++++++++++++++++++++++++--
systemfixtures/tests/test_executable.py | 26 ++++++++++-----
test | 14 --------
tox.ini | 35 +++++---------------
24 files changed, 233 insertions(+), 85 deletions(-)
diff --git a/.coveragerc.py27 b/.coveragerc.py2
similarity index 100%
rename from .coveragerc.py27
rename to .coveragerc.py2
diff --git a/.coveragerc.py35 b/.coveragerc.py3
similarity index 64%
rename from .coveragerc.py35
rename to .coveragerc.py3
index 9fabaaa..2c0d124 100644
--- a/.coveragerc.py35
+++ b/.coveragerc.py3
@@ -1,4 +1,4 @@
[report]
exclude_lines =
- # pragma: no cover
+ pragma: no cover
if six.PY2:
diff --git a/.testr.conf b/.testr.conf
deleted file mode 100644
index aa88c6a..0000000
--- a/.testr.conf
+++ /dev/null
@@ -1,4 +0,0 @@
-[DEFAULT]
-test_command=./test $LISTOPT $IDOPTION
-test_id_option=--load-list $IDFILE
-test_list_option=--list
diff --git a/AUTHORS b/AUTHORS
index 2998bc2..3252dde 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,2 +1 @@
Free Ekanayaka <free.ekanayaka at gmail.com>
-Free Ekanayaka <free at ekanayaka.io>
diff --git a/ChangeLog b/ChangeLog
index 2f97ad8..4ec6a1b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,15 @@
CHANGES
=======
+0.6.2
+-----
+
+* Add a mailmap file for unique AUTHORS entries
+* Add logging to FakeExecutable.hang()
+* Point the README to Read the Docs
+* Streamline development process
+* Make the FakeExecutableTest.test_listen test more robust
+
0.6.1
-----
diff --git a/HACKING.rst b/HACKING.rst
new file mode 100644
index 0000000..1502cd5
--- /dev/null
+++ b/HACKING.rst
@@ -0,0 +1,56 @@
+Run the tests
+=============
+
+You can run the tests using either system packages or a tox-generated virtualenv.
+
+System packages
+---------------
+
+Using system packages makes test runs significantly faster.
+
+If you are on a Debian-based system, install the relevant dependencies
+once with:
+
+.. code:: shell
+
+ make dependencies
+
+Then you can run tests with:
+
+.. code:: shell
+
+ make
+
+The default Python version is 2, to run tests against Python 3 just
+prepend `PYTHON=python3` to the make commands above, for
+example:
+
+.. code:: shell
+
+ PYTHON=python3 make
+
+Tox
+---
+
+Using tox to run the tests is easier since you won't have to deal with
+not-packaged or not-recent-enough versions in your system, but it's also
+a tad slower. Just run:
+
+.. code:: shell
+
+ tox
+
+Cutting a release
+=================
+
+Tag and sign the new version:
+
+.. code:: shell
+
+ git tag -s X.Y.Z
+
+Upload to PyPI:
+
+.. code:: shell
+
+ python3 setup.py sdist bdist_wheel upload -r pypi --sign -i <your key>
diff --git a/MANIFEST.in b/MANIFEST.in
index cef3c93..dd792a6 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1 +1,2 @@
exclude .travis.yml
+exclude .mailmap
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..4b675c4
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,44 @@
+PYTHON ?= python
+PYTHON_MAJOR = $(shell $(PYTHON) -c "import sys; print(sys.version_info.major)")
+
+# These paths are valid on Debian-based systems, on other systems you
+# might have to set these variables from the command line.
+COVERAGE ?= $(PYTHON)-coverage
+SPHINXBUILD ?= /usr/share/sphinx/scripts/python$(PYTHON_MAJOR)/sphinx-build
+
+SOURCE = systemfixtures
+
+all: check check-doc
+
+check:
+ rm -f .coverage
+ $(COVERAGE) run --source=$(SOURCE) -m testtools.run discover
+ $(COVERAGE) report -m --fail-under=100 --rcfile=.coveragerc.py$(PYTHON_MAJOR)
+
+check-doc:
+ SPHINXBUILD=$(SPHINXBUILD) $(MAKE) -C doc doctest
+
+dependencies: dependencies-python$(PYTHON_MAJOR)
+ sudo apt-get install \
+ $(PYTHON)-pbr \
+ $(PYTHON)-six \
+ $(PYTHON)-fixtures \
+ $(PYTHON)-testtools \
+ $(PYTHON)-requests-mock \
+ $(PYTHON)-fakesleep \
+ $(PYTHON)-coverage \
+ $(PYTHON)-sphinx
+
+dependencies-python2:
+ sudo apt-get install \
+ $(PYTHON)-subprocess32
+
+dependencies-python3):
+
+clean:
+ rm -rf $(SOURCE).egg-info dist
+ rm -f AUTHORS ChangeLog
+ find -type f -name "*.pyc" | xargs rm -f
+ find -type d -name "__pycache_" | xargs rm -rf
+
+.PHONY: all check check-doc dependencies dependencies-python2 dependencies-python3
diff --git a/PKG-INFO b/PKG-INFO
index 2d5e0e4..a677058 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: systemfixtures
-Version: 0.6.1
+Version: 0.6.2
Summary: Test fixtures for providing fake versions of various system resources (processes, users, groups, etc.)
Home-page: https://github.com/freeekanayaka/systemfixtures
Author: Free Ekanayaka
@@ -17,10 +17,14 @@ Description: System fixtures
:target: https://travis-ci.org/freeekanayaka/systemfixtures
:alt: Build Status
- .. image:: https://coveralls.io/repos/github/freeekanayaka/charm-test/badge.svg?branch=master
- :target: https://coveralls.io/github/freeekanayaka/charm-test?branch=master
+ .. image:: https://coveralls.io/repos/github/freeekanayaka/systemfixtures/badge.svg?branch=master
+ :target: https://coveralls.io/github/freeekanayaka/systemfixtures?branch=master
:alt: Coverage
+ .. image:: https://readthedocs.org/projects/systemfixtures/badge/?version=latest
+ :target: http://systemfixtures.readthedocs.io/en/latest/?badge=latest
+ :alt: Documentation Status
+
A collection of Python fixtures_ to fake out various system resources (processes,
users, groups, etc.).
@@ -53,7 +57,7 @@ Description: System fixtures
Support and Documentation
-------------------------
- See the `online documentation <http://pythonhosted.org/systemfixtures/>`_ for
+ See the `online documentation <http://systemfixtures.readthedocs.io/>`_ for
a complete reference.
Developing and Contributing
diff --git a/README.rst b/README.rst
index 474004d..e9a7c6d 100644
--- a/README.rst
+++ b/README.rst
@@ -9,10 +9,14 @@ System fixtures
:target: https://travis-ci.org/freeekanayaka/systemfixtures
:alt: Build Status
-.. image:: https://coveralls.io/repos/github/freeekanayaka/charm-test/badge.svg?branch=master
- :target: https://coveralls.io/github/freeekanayaka/charm-test?branch=master
+.. image:: https://coveralls.io/repos/github/freeekanayaka/systemfixtures/badge.svg?branch=master
+ :target: https://coveralls.io/github/freeekanayaka/systemfixtures?branch=master
:alt: Coverage
+.. image:: https://readthedocs.org/projects/systemfixtures/badge/?version=latest
+ :target: http://systemfixtures.readthedocs.io/en/latest/?badge=latest
+ :alt: Documentation Status
+
A collection of Python fixtures_ to fake out various system resources (processes,
users, groups, etc.).
@@ -45,7 +49,7 @@ back to the real behavior for the rest.
Support and Documentation
-------------------------
-See the `online documentation <http://pythonhosted.org/systemfixtures/>`_ for
+See the `online documentation <http://systemfixtures.readthedocs.io/>`_ for
a complete reference.
Developing and Contributing
diff --git a/docs/Makefile b/doc/Makefile
similarity index 99%
rename from docs/Makefile
rename to doc/Makefile
index aa62dd4..5cef3ee 100644
--- a/docs/Makefile
+++ b/doc/Makefile
@@ -3,7 +3,7 @@
# You can set these variables from the command line.
SPHINXOPTS =
-SPHINXBUILD = sphinx-build
+SPHINXBUILD ?= sphinx-build
PAPER =
BUILDDIR = _build
diff --git a/docs/_static/.placeholder b/doc/_static/.placeholder
similarity index 100%
rename from docs/_static/.placeholder
rename to doc/_static/.placeholder
diff --git a/docs/conf.py b/doc/conf.py
similarity index 100%
rename from docs/conf.py
rename to doc/conf.py
diff --git a/docs/index.rst b/doc/index.rst
similarity index 100%
rename from docs/index.rst
rename to doc/index.rst
diff --git a/requirements.txt b/requirements.txt
index 0cdd920..fbe1047 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -4,3 +4,4 @@ fixtures
testtools
requests-mock
fakesleep
+subprocess32; python_version < '3.5'
diff --git a/setup.cfg b/setup.cfg
index 50c513d..938cea5 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -18,8 +18,7 @@ packages = systemfixtures
[extras]
test =
coverage>=4.2
- python_subunit
- testrepository
+ sphinx
[bdist_wheel]
universal = 1
@@ -33,7 +32,7 @@ all_files = 1
upload-dir = docs/_build/html
[egg_info]
-tag_date = 0
-tag_build =
tag_svn_revision = 0
+tag_build =
+tag_date = 0
diff --git a/systemfixtures.egg-info/PKG-INFO b/systemfixtures.egg-info/PKG-INFO
index 2d5e0e4..a677058 100644
--- a/systemfixtures.egg-info/PKG-INFO
+++ b/systemfixtures.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: systemfixtures
-Version: 0.6.1
+Version: 0.6.2
Summary: Test fixtures for providing fake versions of various system resources (processes, users, groups, etc.)
Home-page: https://github.com/freeekanayaka/systemfixtures
Author: Free Ekanayaka
@@ -17,10 +17,14 @@ Description: System fixtures
:target: https://travis-ci.org/freeekanayaka/systemfixtures
:alt: Build Status
- .. image:: https://coveralls.io/repos/github/freeekanayaka/charm-test/badge.svg?branch=master
- :target: https://coveralls.io/github/freeekanayaka/charm-test?branch=master
+ .. image:: https://coveralls.io/repos/github/freeekanayaka/systemfixtures/badge.svg?branch=master
+ :target: https://coveralls.io/github/freeekanayaka/systemfixtures?branch=master
:alt: Coverage
+ .. image:: https://readthedocs.org/projects/systemfixtures/badge/?version=latest
+ :target: http://systemfixtures.readthedocs.io/en/latest/?badge=latest
+ :alt: Documentation Status
+
A collection of Python fixtures_ to fake out various system resources (processes,
users, groups, etc.).
@@ -53,7 +57,7 @@ Description: System fixtures
Support and Documentation
-------------------------
- See the `online documentation <http://pythonhosted.org/systemfixtures/>`_ for
+ See the `online documentation <http://systemfixtures.readthedocs.io/>`_ for
a complete reference.
Developing and Contributing
diff --git a/systemfixtures.egg-info/SOURCES.txt b/systemfixtures.egg-info/SOURCES.txt
index c250fb9..ff5eb7d 100644
--- a/systemfixtures.egg-info/SOURCES.txt
+++ b/systemfixtures.egg-info/SOURCES.txt
@@ -1,20 +1,20 @@
-.coveragerc.py27
-.coveragerc.py35
-.testr.conf
+.coveragerc.py2
+.coveragerc.py3
AUTHORS
ChangeLog
+HACKING.rst
LICENSE
MANIFEST.in
+Makefile
README.rst
requirements.txt
setup.cfg
setup.py
-test
tox.ini
-docs/Makefile
-docs/conf.py
-docs/index.rst
-docs/_static/.placeholder
+doc/Makefile
+doc/conf.py
+doc/index.rst
+doc/_static/.placeholder
systemfixtures/__init__.py
systemfixtures/_overlay.py
systemfixtures/executable.py
diff --git a/systemfixtures.egg-info/pbr.json b/systemfixtures.egg-info/pbr.json
index 52e0ef9..2893350 100644
--- a/systemfixtures.egg-info/pbr.json
+++ b/systemfixtures.egg-info/pbr.json
@@ -1 +1 @@
-{"is_release": true, "git_version": "964369c"}
\ No newline at end of file
+{"git_version": "556c8fe", "is_release": true}
\ No newline at end of file
diff --git a/systemfixtures.egg-info/requires.txt b/systemfixtures.egg-info/requires.txt
index fd57615..bd4cb01 100644
--- a/systemfixtures.egg-info/requires.txt
+++ b/systemfixtures.egg-info/requires.txt
@@ -5,7 +5,9 @@ testtools
requests-mock
fakesleep
+[:(python_version < '3.5')]
+subprocess32
+
[test]
coverage>=4.2
-python_subunit
-testrepository
+sphinx
diff --git a/systemfixtures/executable.py b/systemfixtures/executable.py
index 38fee19..b85fd18 100644
--- a/systemfixtures/executable.py
+++ b/systemfixtures/executable.py
@@ -1,14 +1,20 @@
import os
import socket
+import six
+
+from testtools.content import Content
+from testtools.content_type import UTF8_TEXT
+
from fixtures import (
Fixture,
TempDir,
)
-
-SUBSTITUTIONS = {
-}
+if six.PY2:
+ import subprocess32 as subprocess
+if six.PY3:
+ import subprocess
class FakeExecutable(Fixture):
@@ -19,6 +25,15 @@ class FakeExecutable(Fixture):
self.line("#!/usr/bin/env python")
os.chmod(self.path, 0o0755)
+ self._process = None
+ self.addDetail("fake-process", Content(UTF8_TEXT, self._process_info))
+
+ def spawn(self):
+ """Spawn the fake executable using subprocess.Popen."""
+ self._process = subprocess.Popen(
+ [self.path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ self.addCleanup(self._process_kill)
+
def out(self, text):
self.line("import sys")
self.line("sys.stdout.write('{}\\n')".format(text))
@@ -32,21 +47,58 @@ class FakeExecutable(Fixture):
self.line("import time")
self.line("import signal")
self.line("signal.signal(signal.SIGTERM, lambda *args: None)")
+ self.out("hanging")
self.line("while True: time.sleep(1)")
def listen(self, port=None):
+ """Make the fake executable listen to the specified port.
+
+ Possible values for 'port' are:
+
+ - None: Allocate immediately a free port and instruct the fake
+ executable to use it when it's invoked. This is subject to
+ a race condition, if that port that was free when listen() was
+ invoked later becomes used before the fake executable had chance
+ to bind to it. However it has the advantage of exposing the
+ free port as FakeExecutable.port instance variable, that can easily
+ be consumed by tests.
+
+ - An integer: Listen to this specific port.
+ """
if port is None:
port = allocate_port()
self.port = port
self.line("import socket")
self.line("sock = socket.socket()")
self.line("sock.bind(('localhost', {}))".format(self.port))
+ self.out("listening: %d" % self.port)
self.line("sock.listen(0)")
def line(self, line):
with open(self.path, "a") as fd:
fd.write("{}\n".format(line))
+ def _process_kill(self):
+ """Kill the fake executable process if it's still running."""
+ if self._process.poll() is None: # pragma: no cover
+ self._process.kill()
+ self._process.wait(timeout=5)
+
+ def _process_info(self):
+ """Return details about the fake process."""
+ if not self._process:
+ return []
+
+ output, error = self._process.communicate(timeout=5)
+ if error is None:
+ error = b""
+ output = output.decode("utf-8").strip()
+ error = error.decode("utf-8").strip()
+ info = (u"returncode: %r\n"
+ u"output:\n%s\n"
+ u"error:\n%s\n" % (self._process.returncode, output, error))
+ return [info.encode("utf-8")]
+
def get_port(socket):
"""Return the port to which a socket is bound."""
diff --git a/systemfixtures/tests/test_executable.py b/systemfixtures/tests/test_executable.py
index ef222cc..2d59474 100644
--- a/systemfixtures/tests/test_executable.py
+++ b/systemfixtures/tests/test_executable.py
@@ -1,4 +1,6 @@
import os
+import time
+import errno
import socket
import subprocess
@@ -34,16 +36,22 @@ class FakeExecutableTest(TestCase):
def test_listen(self):
self.executable.listen(6666)
- self.executable.out("hello")
- process = subprocess.Popen(
- [self.executable.path], stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT)
- self.addCleanup(process.wait)
- self.addCleanup(process.kill)
- # This ensures that the port will be open
- self.assertEqual(b"hello\n", process.stdout.read(6))
+ self.executable.sleep(1)
+ self.executable.spawn()
+
+ # Try to connect to the socket
sock = socket.socket()
- sock.connect(("127.0.0.1", self.executable.port))
+ transient = (errno.ECONNREFUSED, errno.ECONNRESET)
+
+ for i in range(5):
+ try:
+ sock.connect(("127.0.0.1", self.executable.port))
+ except socket.error as error: # pragma: no cover
+ if error.errno in transient and i != 4:
+ time.sleep(0.01 * i)
+ continue
+ raise error
+ break
self.assertEqual("127.0.0.1", sock.getsockname()[0])
def test_hang(self):
diff --git a/test b/test
deleted file mode 100755
index 7ddde83..0000000
--- a/test
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env python
-import os
-import six
-
-from coverage.control import Coverage
-from subunit.run import main
-
-
-coverage = Coverage(source=["systemfixtures"], auto_data=True)
-coverage.exclude("# pragma: no cover")
-
-coverage.start()
-main()
-coverage.stop()
diff --git a/tox.ini b/tox.ini
index 9cd8082..c717850 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,36 +1,19 @@
[tox]
-envlist = py27,py35,docs27,docs35
+envlist = py27,py35
skipsdist = True
[tox:travis]
-2.7 = py27,docs27
-3.5 = py35,docs35
+2.7 = py27
+3.5 = py35
[testenv]
usedevelop = True
install_command = pip install -U {opts} {packages}
deps = .[test]
-whitelist_externals = rm
+setenv =
+ COVERAGE=coverage
+ SPHINXBUILD=sphinx-build
+whitelist_externals =
+ make
commands =
- rm -rf .testrepository
- testr init
- testr run
- coverage report -m --skip-covered --fail-under=100 --rcfile=.coveragerc.{envname}
-
-[testenv:docs27]
-basepython = python2.7
-changedir = docs
-deps =
- sphinx
-commands =
- sphinx-build -W -b doctest -d {envtmpdir}/doctrees . {envtmpdir}/doctest
-
-[testenv:docs35]
-basepython = python3.5
-changedir = docs
-deps =
- sphinx
-commands =
- sphinx-build -W -b doctest -d {envtmpdir}/doctrees . {envtmpdir}/doctest
- # Build HTML files so they can by uploaded to PyPI by Travis.
- sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/doctest
+ make
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/systemfixtures.git
More information about the Python-modules-commits
mailing list