Skip to main content

Blender addons tester for Pytest.

Project description

pytest-blender

PyPI Python versions License Tests

Pytest plugin for Blender testing. Executes your pytest testsuite with Blender in headless mode using its builtin Python interpreter.

Install

pip install pytest-blender

Documentation

Usage

Install dependencies in Blender Python interpreter

Before execute it, you need to install your testing dependencies inside the builtin Blender Python interpreter. To get the interpreter location you can use the CLI utility pytest-blender, something like:

blender_python="$(pytest-blender)"
$blender_python -m ensurepip
$blender_python -m pip install -r test-requirements.txt

You can also get the intepreter for a custom Blender installation location with --blender-executable option:

pytest-blender --blender-executable ~/blender-2.91.2-linux64/blender

Execute tests

After installing dependencies, just call pytest as usually.

pytest -svv
Blender 2.82 (sub 7)
Read prefs: ~/.config/blender/2.82/config/userpref.blend
========================= test session starts ==================================
platform linux -- Python 3.8.5, pytest-6.1.2, py-1.9.0, pluggy-0.13.1 -- /usr/bin/blender
cachedir: .pytest_cache
rootdir: /home/mondeja/files/code/pytest-blender
collected 1 item

tests/test_bpy_import.py::test_inside_blender <module 'bpy' from '/usr/share/blender/scripts/modules/bpy/__init__.py'>
PASSED
=========================== 1 passed in 0.01s ==================================

Just can specify a custom blender executable path using --blender-executable option:

pytest --blender-executable ~/blender-2.91.2-linux64/blender
Blender 2.91.2 (hash 5be9ef417703 built 2021-01-19 16:16:34)
Read prefs: ~/.config/blender/2.91/config/userpref.blend
found bundled python: ~/blender-2.91.2-linux64/2.91/python
============================ test session starts ===============================
platform linux -- Python 3.7.7, pytest-6.2.2, py-1.10.0, pluggy-0.13.1
rootdir: ~/pytest-blender
collected 1 item

tests/test_bpy_import.py .                                                [100%]

============================== 1 passed in 0.00s ===============================

Reference

Fixtures

# blender_executablestr

Returns the path of the executable that has started the current Blender session.

# blender_versionstr

Returns the version of Blender running in the current session.

# blender_python_executablestr

Returns the path of the Python executable builtin in the Blender release of the currently running session.

# blender_python_versionstr

Returns the version of the Python executable builtin in the Blender release of the currently running session.

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

pytest_blender-0.0.3.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

pytest_blender-0.0.3-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest_blender-0.0.3.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

File hashes

Hashes for pytest_blender-0.0.3.tar.gz
Algorithm Hash digest
SHA256 0f45fa70b68a56920e6242c22d6ca6a39f6ada14694dc49c04ddce5ee33205ea
MD5 bdcaa2d3701d7eaf6eb80ce8d74e6ab8
BLAKE2b-256 3e46fcf60e723a23bba2f745a9256270c556d4e00d39fe7393e31472ebcdee09

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytest_blender-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

File hashes

Hashes for pytest_blender-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cc721854a3d13719d16b48e3b481a2e98a2d1e784c99da0a3dd49c2ef8edada5
MD5 493ba0dc67b65aa17495f22b0c8502b2
BLAKE2b-256 d5af740dde6a9bf70f9e84a8455b84036596d6bf076a96618a0e19b4489dd8c1

See more details on using hashes here.

Supported by

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