Skip to main content

Mock brython functions for local testing and debugging.

Project description

mockbrython

Mock brython functions for local testing and debugging.

Brython is designed to enable python as a scripting language for the Web. Python scripts are uploaded to a web browser and interpreted by the Brython interpreter that is uploaded along with the python scripts. There are a number of Brython modules that provide web-specific functions to create the web page which are implemented by the interpreter.

When developing applications it is useful to test for syntax errors and debug logic before loading web pages. This small collection of files enables this. They provide a set of dummy modules that mirror the Brython modules, but blank off all the Brython-specific calls to enable the python interpreter to syntax scan the scripts and enable a debugger to exercise the logic. Obviously it doesn't do much for the web-specific part of your design, but it means that the logic is fairly sound when the pages are loaded. Also, an IDE source assistant can use the definitions to prompt function parameters etc.

At first sight, this is fairly trivial, but it took some effort to get right, so I felt it worth publishing.

The library is installable using pip and wont interfere with the Brython interpreter when the pages are uploaded. This is the recommended method, but if you prefer you can clone this directory to a directory OUTSIDE the script you are developing and add the directory to PYTHONPATH eg

$ export PYTHONPATH=${PYTHONPATH}:${HOME}/mockbrython

then running a script containing brython calls will catch syntax errors without hitting unresolved Brython calls

$ python devel_script.py

The script can also be debugged using idle, our your IDE of choice.

There is a simple example in the examples directory. The script sample.py can be run from examples/index.html, or from the command line as

$ cd ${HOME}/mockbrython/examples ; python test.py

This includes a simulated event (a button click).

The script brythontest.py contains all the sample scripts in the section "Brython-specific built-in modules" from the documentation part of the Brython website and should run locally without errors and can be inpected with a debugger.

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

mockbrython-0.0.3.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mockbrython-0.0.3-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file mockbrython-0.0.3.tar.gz.

File metadata

  • Download URL: mockbrython-0.0.3.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.2

File hashes

Hashes for mockbrython-0.0.3.tar.gz
Algorithm Hash digest
SHA256 890b0a46368bfc5de742189515bf61fa8b8ca7f2a166c9dcf281a8682942674f
MD5 176f18087c91ad59a627d4fe59aede43
BLAKE2b-256 419ca2bd04d8f0a4aa912c91180fff51e08b2fb863e08691a841006f045b3eef

See more details on using hashes here.

File details

Details for the file mockbrython-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: mockbrython-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.2

File hashes

Hashes for mockbrython-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9a2a575d80efefe7bc1b3e74a6b66d46b8f4841124c63d47317580db445cf49b
MD5 f87ab2fd0bf3d05439a47ab741a87395
BLAKE2b-256 ea7bcb161a037e68ee2638daef129c36eaa9f8768e2c854497356ad97843178b

See more details on using hashes here.

Supported by

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