I'm writing an app in python, which I will run in docker. Therefore I want to test it in docker as well. I'm working in spacemacs and want to use the tools available to test.

With projectile this is possible, I can call projectile-test-project and give the command: docker-compose run --rm mycontainer pytest tests/

However it would be nice if I could use some of the Python layer functions such as python-test-one. This doesn't work because it will call the command py.test -x -s path/to/file...

I would really like to be able to change that command to something that starts with docker-compose. I think this should be doable, but I don't know much about lisp. How can I do this?


Alright, maybe no one cares, but I fixed it.

You call M-x add-dir-local-variable Choose the mode: python-mode choose the variable: pytest-global-name and the value: docker-compose run --rm <<your_container>> pytest

Now the function pytest-test-one will call the new command. It didn't work for me yet because the folder structure is different in the container. So I solved that by just adding the same directory's in the container.

RUN mkdir -p /home/<<user_name>>/projects/project
RUN ln -s /app /home/<<user_name>>/projects/project

I suppose this not an ideal solution, but for me since I work alone this is fine. I was also looking if its possible to change the path with some configuration as well. And you can only change the path of the project location, which you don't want to change because that's also where your docker-compose file should be.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.