Skip to main content

Blender addons tester for Pytest.

Project description

pytest-blender

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

Install

pip install pytest-blender

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
metadata: {'Python': '3.8.5', 'Platform': 'Linux-5.4.0-65-generic-x86_64-with-glibc2.29',
           'Packages': {'pytest': '6.1.2', 'py': '1.9.0', 'pluggy': '0.13.1'},
           'Plugins': {'metadata': '1.11.0', 'cov': '2.10.1', 'html': '3.1.1'}}
rootdir: /home/mondeja/files/code/pytest-blender
plugins: metadata-1.11.0, cov-2.10.1, html-3.1.1
collected 1 item

tests/test_import_bpy.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_import_bpy.py .                                                [100%]

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

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.1.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

pytest_blender-0.0.1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest_blender-0.0.1.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

File hashes

Hashes for pytest_blender-0.0.1.tar.gz
Algorithm Hash digest
SHA256 9da92e8603d16d327e288dd3810c8e67ca875e96096f7a19d46187fa8709cb88
MD5 c5526f396a7546718aa12c36137fd068
BLAKE2b-256 645abd38f263525a40ead5c326b8cc5c07d952f49a888a56dd8503b050933298

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytest_blender-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

File hashes

Hashes for pytest_blender-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a4a7728ae1036b7e47f3b0945708dccea21185ed2ee3e8462ca684d56f585e33
MD5 9361772274ffc4f871dd9e1d9900e5a3
BLAKE2b-256 402653ea3fdea16f34b61c6dcb314f6e729cb19f6cb947ccc986fd95d4317c50

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