Pycharm - docker-compose testing and coverage with a pure python project

For a Django project, I can get coverage and unit tests to run inside the windows provided by PyCharm. However, when working with a pure python project (for a future command line program), I can't seem to get docker-compose to integrate or be recognized by the testing / coverage windows. For example, instead of the test dialog popping up, I have to look at the log in the docker window  o see the results. 

Does anyone have experience setting up a pure python project with docker-compose as the interpreter? If so, could you share a reproducible example of your Dockerfile + docker-compose and any commands you run to integrate with PyCharm?

This is what I have right now: 

Dockerfile: 

FROM python:3.6
COPY requirements.txt /
RUN pip install -r /requirements.txt

 docker-compose.yml

version: '2'

services:
sut:
build:
context: .
dockerfile: Dockerfile
command: "bash -c 'cd /app && python -m unittest discover'"
volumes:
- .:/app
0
8 comments

Hi Brandon,

I'm not sure why you're facing this problem, but I've tested with docker-compose interpreter and I get the tests and coverage working just fine, here's a screenshot showing both coverage and test windows for a docker-compose project:

 

Is this what you're trying to achieve? Feel free to take a look at the project sample: http://bit.ly/2RZzPN6

0

could you please show the test settings? I'm stuck on it too. 

0

Here's some screenshot of tests running successfully in a simple Django project using docker-compose interpreter.

0

Andrey Resler yes but with coverage?  Did you try? 

0

Sure, the test coverage works as well

The settings are the same as previous post.

It's working both using bundled and non-bundled coverage (settings at Preferences | Build, Execution, Deployment | Coverage), in the latter case, you have to install coverage using Dockerfile. Please try it both ways.

1

Do you have the same settings?
And do you have .coveragerc ? file 
and if yes what you put inside?

0

Yes, same as yours. For me it's working without .coveragerc config.

Here's the project I'm testing with, may be you could try it as well: https://andrey-resler@bitbucket.org/andrey-resler/django_test.git

Just a the Dockerfile and docker-compose.yml and create an interpreter from that.

0

Please sign in to leave a comment.