So I am trying to use the coverage.py tool to measure the code coverage of my Django app, however, I have had 0 success today. Basically, my plan was after running the docker container, to have a process manager execute a .sh
file, containing the following 2 lines: coverage run /path/to/manage.py test nameofapp
and coverage html -d coverage_html"
. The problem is that the html file is not being created and I am basically getting 0 information about the coverage. After entering the docker container using docker exec -it nameofcontainer bash
and reading the logs I found the following error:
----------------------------------------------------------------------
Ran 12 tests in 0.081s
OK
>>> Creating test database for alias 'default'...
Destroying test database for alias 'default'...
Traceback (most recent call last):
File "/usr/bin/coverage", line 9, in <module> load_entry_point('coverage==4.3.4', 'console_scripts', 'coverage')()
File "/usr/lib/python3.4/site-packages/coverage/cmdline.py", line 756, in main status = CoverageScript().command_line(argv)
File "/usr/lib/python3.4/site-packages/coverage/cmdline.py", line 483, in command_line return self.do_run(options, args)
File "/usr/lib/python3.4/site-packages/coverage/cmdline.py", line 641, in do_run self.coverage.save()
File "/usr/lib/python3.4/site-packages/coverage/control.py", line 742, in save self.data_files.write(self.data, suffix=self.data_suffix)
File "/usr/lib/python3.4/site-packages/coverage/data.py", line 673, in write data.write_file(filename)
File "/usr/lib/python3.4/site-packages/coverage/data.py", line 460, in write_file with open(filename, 'w') as fdata:
PermissionError: [Errno 13] Permission denied: '/.coverage'
So after seeing the lack of permissions on /.coverage, I simply added chmod +x /path/to/.coverage
, however, this made 0 difference and I yet received the exact same error. I decided to enter the container once more and execute the script myself and to my surprise, it worked flawlessly. So why am I not capable of executing the .sh
file using the process manager? Is it because the /.coverage
file is created once I run the first coverage command and even tho I added the chmod
command I am not really changing the permissions on the file as it still does not exist?