From 31e8e136b4a73499b0457a09dd7bcc4e5d27851b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20=C5=9Awi=C4=99cicki?= Date: Wed, 9 Apr 2014 20:16:06 +0200 Subject: [PATCH 1/5] Update gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index a97e73a..229b1af 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ summon_process.egg-info dist build *.pyc + +.idea/ +atlassian-ide-plugin.xml From 12662b8dd099ff80f85bfc0fc7ea197a36ef4ddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20=C5=9Awi=C4=99cicki?= Date: Wed, 9 Apr 2014 20:37:51 +0200 Subject: [PATCH 2/5] Fix tests --- README.rst | 3 +-- setup.py | 4 ++-- summon_process/executors/simple_executor.py | 17 +++++++++++++---- .../executors/test_http_coordinated_executor.py | 8 +++++++- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/README.rst b/README.rst index 4e92db9..82e5f30 100644 --- a/README.rst +++ b/README.rst @@ -1,8 +1,7 @@ summon_process ============== -**Current status:** work in progress. The code is lacking proper documentation -and is broken on Python 3.3. +**Current status:** work in progress. The code is lacking proper documentation. .. image:: https://travis-ci.org/mlen/summon_process.png?branch=master :target: https://travis-ci.org/mlen/summon_process diff --git a/setup.py b/setup.py index 6f76ffe..2f2ff45 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,9 @@ from setuptools import setup, find_packages setup(name='summon_process', - version='0.1.3', + version='0.1.4', description='Process coordinator for tests', - long_description=file('README.rst').read(), + long_description=open('README.rst').read(), url='https://github.com/mlen/summon_process', author='Mateusz Lenik', author_email='mlen@mlen.pl', diff --git a/summon_process/executors/simple_executor.py b/summon_process/executors/simple_executor.py index e92ed4a..08049b9 100644 --- a/summon_process/executors/simple_executor.py +++ b/summon_process/executors/simple_executor.py @@ -31,11 +31,20 @@ def running(self): return self._process.poll() is None def start(self): + """ + .. note:: + We want to open ``stdin``, ``stdout`` and ``stderr`` as text + streams in universal newlinces mode, so we have to set + ``universal_newlines`` to ``True``. + """ if self._process is None: - self._process = subprocess.Popen(self._args, - shell=self._shell, - stdin=subprocess.PIPE, - stdout=subprocess.PIPE) + self._process = subprocess.Popen( + self._args, + shell=self._shell, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + universal_newlines=True, + ) if self._timeout: self._endtime = time.time() + self._timeout diff --git a/summon_process/tests/executors/test_http_coordinated_executor.py b/summon_process/tests/executors/test_http_coordinated_executor.py index dc301b6..6c85d78 100644 --- a/summon_process/tests/executors/test_http_coordinated_executor.py +++ b/summon_process/tests/executors/test_http_coordinated_executor.py @@ -1,7 +1,13 @@ import os from unittest import TestCase -from httplib import HTTPConnection, OK + + +try: + from httplib import HTTPConnection, OK +except ImportError: + # In python3 httplib is renamed to http.client + from http.client import HTTPConnection, OK from summon_process.executors import HTTPCoordinatedExecutor, TimeoutExpired From 58ac69158e0af0fa33da8e675b9290bfe49a4c6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomek=20=C5=9Awi=C4=99cicki?= Date: Thu, 10 Apr 2014 10:37:23 +0200 Subject: [PATCH 3/5] Update simple_executor.py --- summon_process/executors/simple_executor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/summon_process/executors/simple_executor.py b/summon_process/executors/simple_executor.py index 08049b9..263c97b 100644 --- a/summon_process/executors/simple_executor.py +++ b/summon_process/executors/simple_executor.py @@ -34,7 +34,7 @@ def start(self): """ .. note:: We want to open ``stdin``, ``stdout`` and ``stderr`` as text - streams in universal newlinces mode, so we have to set + streams in universal newlines mode, so we have to set ``universal_newlines`` to ``True``. """ if self._process is None: From 335dfb38476e6986ad4a5906dd4a1381f2cec792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20=C5=9Awi=C4=99cicki?= Date: Mon, 14 Apr 2014 23:09:02 +0200 Subject: [PATCH 4/5] Fix imports (python3) --- .../executors/test_http_coordinated_executor.py | 6 +++++- summon_process/tests/slow_server.py | 15 +++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/summon_process/tests/executors/test_http_coordinated_executor.py b/summon_process/tests/executors/test_http_coordinated_executor.py index 6c85d78..4800c19 100644 --- a/summon_process/tests/executors/test_http_coordinated_executor.py +++ b/summon_process/tests/executors/test_http_coordinated_executor.py @@ -5,9 +5,11 @@ try: from httplib import HTTPConnection, OK + http_server = "SimpleHTTPServer" except ImportError: # In python3 httplib is renamed to http.client from http.client import HTTPConnection, OK + http_server = "http.server" from summon_process.executors import HTTPCoordinatedExecutor, TimeoutExpired @@ -17,7 +19,9 @@ class TestHTTPCoordinatedExecutor(TestCase): port = "8000" def test_it_waits_for_process_to_complete_head_request(self): - command = 'bash -c "sleep 3 && exec python -m SimpleHTTPServer"' + command = 'bash -c "sleep 3 && exec python -m {http_server}"'.format( + http_server=http_server, + ) executor = HTTPCoordinatedExecutor( command, 'http://{0}:{1}/'.format(self.host, self.port) ) diff --git a/summon_process/tests/slow_server.py b/summon_process/tests/slow_server.py index f0dce69..a9ccfa5 100644 --- a/summon_process/tests/slow_server.py +++ b/summon_process/tests/slow_server.py @@ -1,9 +1,16 @@ import time -from BaseHTTPServer import ( - HTTPServer, - BaseHTTPRequestHandler, -) +try: + from BaseHTTPServer import ( + HTTPServer, + BaseHTTPRequestHandler, + ) +except ImportError: + # In python3 httplib is renamed to http.client + from http.server import ( + HTTPServer, + BaseHTTPRequestHandler, + ) class SlowServerHandler(BaseHTTPRequestHandler): From 50a0eaf821c949bf38522753824b9ce8eebad762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomek=20=C5=9Awi=C4=99cicki?= Date: Tue, 15 Apr 2014 11:07:53 +0200 Subject: [PATCH 5/5] Update slow_server.py --- summon_process/tests/slow_server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/summon_process/tests/slow_server.py b/summon_process/tests/slow_server.py index a9ccfa5..6903673 100644 --- a/summon_process/tests/slow_server.py +++ b/summon_process/tests/slow_server.py @@ -6,7 +6,7 @@ BaseHTTPRequestHandler, ) except ImportError: - # In python3 httplib is renamed to http.client + # python3 from http.server import ( HTTPServer, BaseHTTPRequestHandler,