Skip to main content

Module for making changes in code during runtime

Project description

Dynamic-executor library for changing python code during runtime

Dynamic python is ment to be used in test development for creating and updating tests or wherever the need arises to change the code during runtime and have results visible instantaneously without restarting. The main functionality is provided by exec_in_dynamic_mode generator that reloads all project-root modules (neither builtin not venv modules are reloaded)

Installation

You can install the dynamic-executor package using pip:

pip install dynamic-executor

Or by cloning the repository directly :

git clone git@github.com:Tesla2000/dynamic_executor.git

Access

PyPI: https://pypi.org/project/dynamic-executor/

Github: https://github.com/Tesla2000/dython

Usage

You can go through video tutorial to check utilities of Dynamic Executor https://youtu.be/RZUzBU70eKA.

Here's an example of how to use the exec_in_dynamic_mode function:

# ImportedModuleFaulty.py
from dynamic_executor import DynamicClass


class SomeDynamicClass(DynamicClass):
    def foo(self):
        raise ValueError
# ImportedModuleValid.py
from dynamic_executor import DynamicClass


class SomeDynamicClass(DynamicClass):
    def foo(self):
        pass
# test_executor.py
dynamic_instance.foo()
from dython import exec_in_dynamic_mode
parent = Path(__file__).parent
parent.joinpath("ImportedModule.py").write_text(
    parent.joinpath("ImportedModuleFaulty.py").read_text()
)  # faulty version of imported module
from ImportedModule import SomeDynamicClass
dynamic_instance = SomeDynamicClass()
index = -1
for index, error in enumerate(exec_in_dynamic_mode(locals(), globals(), parent.joinpath("test_executor.py"))):
    if index:
        assert False  # ensuring that the error is corrected
    parent.joinpath("ImportedModule.py").write_text(
        parent.joinpath("ImportedModuleValid.py").read_text()
    )  # correcting module

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dynamic-executor-1.0.10.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

dynamic_executor-1.0.10-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file dynamic-executor-1.0.10.tar.gz.

File metadata

  • Download URL: dynamic-executor-1.0.10.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for dynamic-executor-1.0.10.tar.gz
Algorithm Hash digest
SHA256 d6bf2c9f8e9f7a12d40c6130c70411039a6da7630a59de7cb3a6c716c92074ff
MD5 753c10f1b33ae4a173b67d43b579bb68
BLAKE2b-256 b3457a6feee85739c02456787b5aeeaf5015454b78a6a6241bb9ef9b41d123d2

See more details on using hashes here.

File details

Details for the file dynamic_executor-1.0.10-py3-none-any.whl.

File metadata

File hashes

Hashes for dynamic_executor-1.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 9b3b54a35dc6908dabd150c63fbe2133465e2bf887ac2ccaf215063f42bb0ede
MD5 3fb12577531bbb3099e71cb12353fbd3
BLAKE2b-256 28531e1fb525db744f0c47729b7262118b010ccbc1bbd2f885fb06d82b224fce

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page