Sigmmma / Blendkrieg

Halo Model importer and exporter for Blender.
GNU General Public License v3.0
11 stars 3 forks source link

Add Blendkrieg parent folder to path if test is imported. #34

Closed ShellyHerself closed 4 years ago

ShellyHerself commented 4 years ago

Change the merge branch to whatever you want or need. Here is a basic runthrough of what you need to know after this is there.

Since system Python is different from Blender python you cannot share the dependencies like hamcrest and pocha by just installing them with pip. Luckly, there is an easy solution.

Assuming you are running this from your Blendkrieg directory: Install pip

/path/to/blender/version/python/bin/python3.7m -m ensurepip

Install the dependencies.

/path/to/blender/version/python/bin/python3.7m -m pip install -r dev-dependencies.txt

The "version" part of the path will need to be replaced with whatever version you have in the blender folder. For me it was 2.81. So, I was able to execute.

/home/michelle/Programs/blender-2.81a-linux-glibc217-x86_64/2.81/python/bin/python3.7m -m ensurepip

If done correctly you should have access to pocha and the likes when running python through the Blender binary.

Another challenge though. You can't run Pocha as normal (no access to args like -m). I've added a file called run-pocha.py so pocha can be used as expected when doing a non-Blender project.

/path/to/blender/blender -b --python run-pocha.py

This works as expected and fails the tests because your assert detects that this bpy is not the mock. (I checked and when disabling that assert all tests fail as they should because clear_mock doesn't exist.)

.

.

I think there should be a way to automate this. Maybe you can come up with suggestions :stuck_out_tongue:

(Read the comments btw)

ShellyHerself commented 4 years ago

By the way, because of how Pocha's test searching works the __init__.py hack in test/ is automatically applied whenever you run run-pocha.py through Blender. :heart: