coveragepy / coveragepy/coveragepy
Unable to run coverage tool using embedded python using the -m option or when copied to different path locations in windows
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 3.4k
- Forks
- 525
- Avg merge
- 18h 27m
- Merged PRs (30d)
- 6
Description
I am trying to run the python coverage tool using embedded python downloaded from https://www.python.org/ftp/python/3.6.1/python-3.6.1-embed-amd64.zip
The following are the steps I followed to run a test code using coverage module.
-
After downloading python-3.6.1-embed-amd64.zip, I uncompress the files to D:\some_directory\python-3.6.1-embed-amd64
-
cd python-3.6.1-embed-amd64
-
python get-pip.py
-
python -mpip install coverage
-
python-3.6.1-embed-amd64\python36._pth is changed to
python36.zip
Lib\site-packages
.
# Uncomment to run site.main() automatically
#import site
-
In case if there is an internet proxy to used then use the following command
SET HTTP_PROXY=http://username:password@proxy_ip:proxy_port
-
python -mpip install coverage
Create test files as follows
The file module_prog.py is as follows
# -*- coding: utf-8 -*-
"""
Dummy method for testing
"""
def method_to_tested() -> None:
"""
Method To be tested
"""
print("Called method to be tested")
The file test_module.py is as follows
""" Unit test script for testing File : test_module.py
"""
import unittest
from module_prog import method_to_tested
class TestMethods(unittest.TestCase):
""" Testing the methods """
def test_method_to_tested(self):
method_to_tested()
if __name__ == "__main__":
unittest.main(warnings='ignore')
- I run the following
D:\some_directory\python-3.6.1-embed-amd64>python test_module.py
Called method to be tested
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
- But if I run the instruction as mentioned below using converage I get the following error.
D:\some_directory\python-3.6.1-embed-amd64>python -mcoverage run test_module.py
Traceback (most recent call last):
File "test_module.py", line 4, in <module>
import unittest
ModuleNotFoundError: No module named 'unittest'
If I run the command
Scripts\converage.exe run test_module.py
Then coverage run successfully,
But if I move the embedded python to another directory and try to run the same command as above then I get the following error
D:\some_other_directory\python-3.6.1-embed-amd64>Scripts\coverage.exe run test_module.py
Fatal error in launcher: Unable to create process using
'"d:\some_directory\python-3.6.1-embed-amd64\python.exe" "D:\some_other_directory\python-3.6.1-embed-amd64\Scripts\coverage.exe" run test_module.py'
How can I make coverage run as a python module in case the python is embedded python
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the two commands from the issue with Python 3.6.1 embedded in the reported directory layout. Start by comparing python -m coverage with Scripts\coverage.exe, then check the launcher path shown in the error after moving the directory. Done means coverage runs as a module with embedded Python and the copied launcher no longer references the original path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100