webkitcorepy
Provides a number of utilities intended to support intermediate to advanced Python programming.
Requirements
The requests, six, and tblib libraries.
Usage
Version representation
from webkitcorepy import Version
version = Version(1, 2, 3)
Unicode stream management, designed to ease transition to Python 3
from webkitcorepy import BytesIO, StringIO, UnicodeIO, unicode
Encoding and decoding byte strings and unicode strings
from webkitcorepy import string_utils
string_utils.encode(...)
string_utils.decode(...)
Automatically install libraries on import.
from webkitcorepy import AutoInstall
AutoInstall.register(Package('requests', Version(2, 24)))
import requests
Mocking basic time and sleep calls
import time
from webkitcorepy import mocks
with mocks.Time:
stamp = time.time()
time.sleep(5)
Capturing stdout, stderr and logging output for testing
capturer = OutputCapture()
with capturer:
print('data\n')
assert capturer.stdout.getvalue() == 'data\n'
Capturing stdout, stderr and logging output for testing
capturer = OutputCapture()
with capturer:
print('data\n')
assert capturer.stdout.getvalue() == 'data\n'
Timeout context:
import time
from webkitcorepy import Timeout
with Timeout(5, handler=RuntimeError('Exceeded 5 second timeout')):
time.sleep(4)
subprocess.run replacement:
import sys
from webkitcorepy import run
result = run([sys.executable, '-c', 'print("message")'], capture_output=True, encoding='utf-8')
Mocking of subprocess commands:
from webkitcorepy import mocks, run
with mocks.Subprocess(
'ls', completion=mocks.ProcessCompletion(returncode=0, stdout='file1.txt\nfile2.txt\n'),
):
result = run(['ls'], capture_output=True, encoding='utf-8')
assert result.returncode == 0
assert result.stdout == 'file1.txt\nfile2.txt\n'
The mocking system for subprocess also supports other subprocess APIs based on Popen:
with mocks.Subprocess(
'ls', completion=mocks.ProcessCompletion(returncode=0, stdout='file1.txt\nfile2.txt\n'),
):
assert subprocess.check_output(['ls']) == b'file1.txt\nfile2.txt\n'
assert subprocess.check_call(['ls']) == 0
For writing integration tests, the mocking system for subprocess supports mocking multiple process calls at the same time:
with mocks.Subprocess(
mocks.Subprocess.CommandRoute('command-a', 'argument', completion=mocks.ProcessCompletion(returncode=0)),
mocks.Subprocess.CommandRoute('command-b', completion=mocks.ProcessCompletion(returncode=-1)),
):
result = run(['command-a', 'argument'])
assert result.returncode == 0
result = run(['command-b'])
assert result.returncode == -1
Metadata
Release files for webkitcorepy 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| webkitcorepy-1.0.2.tar.gz | 64.2 kB | Without provenance | Details for webkitcorepy-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| webkitcorepy-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for webkitcorepy-1.0.2-py3-none-any.whl |
Total release size: 180.3 kB
Release files / webkitcorepy-1.0.2.tar.gz
| Download URL | webkitcorepy-1.0.2.tar.gz |
|---|---|
| Size | 64.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
97ebfddff614a88dad9f3dc7f140a3c58c75e7aa85dc6b7d951fe55f9bcc8579
|
|
BLAKE2b-256 checksum How to use checksums |
e2b05f4b602564b264408139cb9b6d730813032b7f74a65b8acc46d0ce8b9400
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / webkitcorepy-1.0.2-py3-none-any.whl
| Download URL | webkitcorepy-1.0.2-py3-none-any.whl |
|---|---|
| Size | 116.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b7e8faa2b333e2816b7411f16e47b0c3cc4adb4bafaf75bd02694d7e7ea9500e
|
|
BLAKE2b-256 checksum How to use checksums |
52346f34cd92baf887c635e0754999fc4d03ac394c2f662b7c00b8ee91b8b717
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for webkitcorepy 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.