Skip to main content

EvasionProject code documentation

EvasionProject Wiki

Introduction

This package provides “evasion.common”. This is a collection of useful functions and other utilities.

evasion.common.net

get_free_port

Find a TCP port locally that is not in use and return it. This finds a random port in the range 2000 - 10000. It tests if it is available by binding to it. It the closed the socket and return the port.

This is quite handy for getting a free port to run a service on while acceptance testing.

Example usage:

from evasion.common import net

# Get a free port:
port1 = net.get_free_port()

# Get another free port excluding the first port from the list
port1 = net.get_free_port(exclude_ports=[port1])

wait_for_ready

Called to wait for a web application to respond to normal requests. This is useful when you want to know a web app is not just bound to a socket, but is actually responding 200 OK to root page downloads.

Example usage from unit tests:

from evasion.common import net
from evasion.common import webhelpers

port1 = net.get_free_port()

# Run the web app and wait for ready should connect:
web = webhelpers.BasicWeb(port=port1)
web.start()

result = net.wait_for_ready(web.uri)
assert result

web.stop()

wait_for_service

Called to wait until a socket connection can be made to a remote service.

Example usage from unit tests:

from evasion.common import net
from evasion.common import webhelpers

port1 = net.get_free_port()

# Run the web app and wait for ready should connect:
web = webhelpers.BasicWeb(port=port1)
web.start()

result = net.wait_for_service('localhost', port1)
assert result

web.stop()

Release files for evasion-common 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for evasion-common 1.0.3
File Size Uploaded
evasion-common-1.0.3.tar.gz 7.1 kB Details

Release files / evasion-common-1.0.3.tar.gz

Download URL evasion-common-1.0.3.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
f677bab3b83b25470af091a39db247aa395c55d44fdd9651f71c5eba4b0c3138
BLAKE2b-256 checksum
How to use checksums
fa948948120dc09a3cb8d0ef618ab1a96810ab614a0b14765817d46c94d17fc5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0.3 This release

1 release file

1.0.2

1 release file

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page