Process executor for tests.
Project description
mirakuru
Maybe you want to be able to start database only when you start your program, or maybe you need just to set up additional processes for your tests, this is where you should consider using mirakuru, to add superpowers to your program, or tests.
Package status
About
As developers, we have to work on project that rely on multiple processes to run. We guard ourselves with tests. But sometimes it’s not enough what one process sends, and the other receives. Sometimes there’s need to actually exchange data between processes. Or write selenium tests. Or maybe write a program that takes care of starting databases or other required services itself.
If so, then mirakuru is what you need.
Mirakuru starts your required process, and wait for clear indication, that it’s running. There are three basic executors with predefined conditions:
Executor - simply starts
OutputExecutor - awaits for specified output to be given by process
TCPExecutor - waits for ability to connect through tcp with process
HTTPExecutor - waits for successful HEAD request (and tcp before)
PidExecutor - waits for a specified file to exist
from mirakuru import HTTPExecutor
from httplib import HTTPConnection, OK
def test_it_works():
executor = HTTPExecutor("./server", url="http://localhost:6543/")
# start and wait for it to run
executor.start()
# should be running!
conn = HTTPConnection("localhost", 6543)
conn.request('GET', '/')
assert conn.getresponse().status is OK
executor.stop()
The server command in this case is just a bash script that sleeps for some time and then launches the builtin SimpleHTTPServer on port 6543.
Command by which executor spawns a process, can be either string or list.
# command as string
TCPExecutor('python -m smtpd -n -c DebuggingServer localhost:1025', host='localhost', port=1025)
# command as list
TCPExecutor(
['python, '-m', 'smtpd', '-n', '-c', 'DebuggingServer', 'localhost:1025'],
host='localhost', port=1025
)
License
mirakuru is licensed under LGPL license, version 3.
Contributing and reporting bugs
Source code is available at: ClearcodeHQ/mirakuru. Issue tracker is located at GitHub Issues. Projects PyPI page.
When contributing, don’t forget to add your name to AUTHORS.rst file.
CHANGELOG
0.4.0
[feature] ability to set up custom signal for stopping and killing proceses managed by executors
[feature] replaced explicit parameters with keywords for kwargs handled by basic Executor init method
[feature] Executor now accepts both list and string as a command
[fix] even it’s not recommended to import all but from mirakuru import * didn’t worked. Now it’s fixed.
[tests] increased tests coverage. Even library covers 100% of code it doesn’t cover 100% of use cases!
[code quality] increased pylint code evaluation.
0.3.0
[feature] PidExecutor that waits for specified file to be created.
pypy compatibility
[fix] closing all resources explicitly
0.2.0
[fix] - kill all children processes of Executor started with shell=True
[feature] executors are now context managers - to start executors for given context
[feature] Executor.stopped - context manager for stopping executors for given context
[feature] HTTPExecutor and TCPExecutor before .start() check whether port is already used by other processes and raise AlreadyRunning if detects it
moved python version conditional imports into compat.py module
0.1.4
fix issue where setting shell to True would execute only part of the command.
0.1.3
fix issue where OutputExecutor would hang, if started process stopped producing output
0.1.2
[fix] removed leftover sleep from TCPExecutor._wait_for_connection
0.1.1
fixed MANIFEST.in
updated packaging options
0.1.0
exposed process attribute on Executor
exposed port and host on TCPExecutor
exposed url on HTTPExecutor
simplified package structure
simplified executors operating api
updated documentation
added docblocks for every function
applied license headers
stripped orchestrators
forked off from summon_process
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mirakuru-0.4.0.tar.gz
.
File metadata
- Download URL: mirakuru-0.4.0.tar.gz
- Upload date:
- Size: 19.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0340446439fa5f3fc0e1ae003feae8143934a41fa8f56257f8dd9e882d7f732a |
|
MD5 | 57b3c339ed7fefa1557f4ab409b93093 |
|
BLAKE2b-256 | 11dbea33ae7af118146b497a0f24f66e473c823fc14825ee3e70c8a2f23725f7 |
File details
Details for the file mirakuru-0.4.0-py2.py3-none-any.whl
.
File metadata
- Download URL: mirakuru-0.4.0-py2.py3-none-any.whl
- Upload date:
- Size: 25.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 947a997a3a6fc94d9f723026963ef761f75acd45375e8bbebb5cff51eef2f754 |
|
MD5 | 114d9efdce695bd4f412472675030e49 |
|
BLAKE2b-256 | d7874769cdee3692ed13f142f2950ba8be9a774593d845bbd5f44c5b5f249975 |