Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ summon_process.egg-info
dist
build
*.pyc

.idea/
atlassian-ide-plugin.xml
3 changes: 1 addition & 2 deletions README.rst
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
17 changes: 13 additions & 4 deletions summon_process/executors/simple_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 newlines 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

Expand Down
14 changes: 12 additions & 2 deletions summon_process/tests/executors/test_http_coordinated_executor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import os

from unittest import TestCase
from httplib import HTTPConnection, OK


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

Expand All @@ -11,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)
)
Expand Down
15 changes: 11 additions & 4 deletions summon_process/tests/slow_server.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import time

from BaseHTTPServer import (
HTTPServer,
BaseHTTPRequestHandler,
)
try:
from BaseHTTPServer import (
HTTPServer,
BaseHTTPRequestHandler,
)
except ImportError:
# python3
from http.server import (
HTTPServer,
BaseHTTPRequestHandler,
)


class SlowServerHandler(BaseHTTPRequestHandler):
Expand Down