Metadata-Version: 2.1
Name: pytest-blender
Version: 0.0.2
Summary: Blender addons tester for Pytest.
Home-page: https://github.com/mondeja/pytest-blender
Author: Álvaro Mondéjar Rubio
Author-email: mondejar1994@gmail.com
License: BSD-3-Clause
Platform: UNKNOWN
Classifier: Framework :: Pytest
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Provides-Extra: dev
Requires-Dist: black (==20.8b1) ; extra == 'dev'
Requires-Dist: bump2version (==1.0.1) ; extra == 'dev'
Requires-Dist: flake8 (==3.8.4) ; extra == 'dev'
Requires-Dist: flake8-implicit-str-concat (==0.2.0) ; extra == 'dev'
Requires-Dist: flake8-print (==4.0.0) ; extra == 'dev'
Requires-Dist: isort (==5.7.0) ; extra == 'dev'
Requires-Dist: pre-commit (==2.9.3) ; extra == 'dev'
Requires-Dist: pytest (==6.2.1) ; extra == 'dev'
Requires-Dist: yamllint (==1.25.0) ; extra == 'dev'
Provides-Extra: lint
Requires-Dist: black (==20.8b1) ; extra == 'lint'
Requires-Dist: flake8 (==3.8.4) ; extra == 'lint'
Requires-Dist: flake8-implicit-str-concat (==0.2.0) ; extra == 'lint'
Requires-Dist: flake8-print (==4.0.0) ; extra == 'lint'
Requires-Dist: isort (==5.7.0) ; extra == 'lint'
Requires-Dist: yamllint (==1.25.0) ; extra == 'lint'
Provides-Extra: test
Requires-Dist: pytest (==6.2.1) ; extra == 'test'

# pytest-blender

[![PyPI][pypi-version-badge-link]][pypi-link]
[![Python versions][pypi-pyversions-badge-link]][pypi-link]
[![License][license-image]][license-link]
[![Tests][tests-image]][tests-link]

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

## Install

```bash
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:

```bash
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:

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

### Execute tests

After installing dependencies, just call pytest as usually.

```bash
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_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:

```bash
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 ===============================
```

[pypi-link]: https://pypi.org/project/pytest-blender
[pypi-version-badge-link]: https://img.shields.io/pypi/v/pytest-blender
[pypi-pyversions-badge-link]: https://img.shields.io/pypi/pyversions/pytest-blender
[license-image]: https://img.shields.io/pypi/l/pytest-blender?color=light-green
[license-link]: https://github.com/mondeja/pytest-blender/blob/master/LICENSE
[tests-image]: https://img.shields.io/github/workflow/status/mondeja/pytest-blender/CI
[tests-link]: https://github.com/mondeja/pytest-blender/actions?query=workflow%3ACI


