Coveragepy: ModuleNotFoundError: No module named 'django_project' when I used coverage run manage.py test

Created on 24 Oct 2019  Β·  37Comments  Β·  Source: nedbat/coveragepy

The below issue is with Coverage version 5.0a7

When trying to run test for my django project using coverage run manage.py test i get
ModuleNotFoundError. This issue kept coming and i thought it was as a result of what was addressed here --> https://stackoverflow.com/questions/50378166/django-coverage-modulenotfounderror-no-module-named-django-extensions

None of the recommendations worked, i downgraded my django version from 3.0 to 2.2 and the problem persisted. This issue was rectified by downgrading to coverage version 4.5

Like i said, i only encountered this issue with coverage version 5.0a7

With the below dependencies, coverage is working as expected

Ξ» pipenv run pip list
Package          Version
---------------- -------
asgiref              3.2.3
coverage          4.5
Django              2.2
Pillow               6.2.1
pip                   19.3.1
psycopg2         2.8.4
pytz                2019.3
setuptools       41.4.0
sqlparse         0.3.0
wheel            0.33.6

complete error log

Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "c:\users\spaceofmiah\.virtualenvs\backend--o8je5ax\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "c:\users\spaceofmiah\.virtualenvs\backend--o8je5ax\lib\site-packages\django\core\management\__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "c:\users\spaceofmiah\.virtualenvs\backend--o8je5ax\lib\site-packages\django\core\management\commands\test.py", line 23, in run_from_argv
    super().run_from_argv(argv)
  File "c:\users\spaceofmiah\.virtualenvs\backend--o8je5ax\lib\site-packages\django\core\management\base.py", line 320, in run_from_argv
    parser = self.create_parser(argv[0], argv[1])
  File "c:\users\spaceofmiah\.virtualenvs\backend--o8je5ax\lib\site-packages\django\core\management\base.py", line 294, in create_parser
    self.add_arguments(parser)
  File "c:\users\spaceofmiah\.virtualenvs\backend--o8je5ax\lib\site-packages\django\core\management\commands\test.py", line 44, in add_arguments
    test_runner_class = get_runner(settings, self.test_runner)
  File "c:\users\spaceofmiah\.virtualenvs\backend--o8je5ax\lib\site-packages\django\test\utils.py", line 301, in get_runner
    test_runner_class = test_runner_class or settings.TEST_RUNNER
  File "c:\users\spaceofmiah\.virtualenvs\backend--o8je5ax\lib\site-packages\django\conf\__init__.py", line 76, in __getattr__
    self._setup(name)
  File "c:\users\spaceofmiah\.virtualenvs\backend--o8je5ax\lib\site-packages\django\conf\__init__.py", line 63, in _setup
    self._wrapped = Settings(settings_module)
  File "c:\users\spaceofmiah\.virtualenvs\backend--o8je5ax\lib\site-packages\django\conf\__init__.py", line 142, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "c:\users\spaceofmiah\.virtualenvs\backend--o8je5ax\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 936, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 936, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'newproject'
bug fixed

Most helpful comment

For those facing this problem: a work-around seems to be to use "python -m coverage run (etc)" instead of "coverage run (etc)".

All 37 comments

Hmm, this sounds concerning. Can you give me a way to reproduce the problem?

I started off by creating a virtual environment in my project directory and activating the virtual environment.

Within the activated environment I installed django and coverage ( didn't explicitly specify any version number, so the latest versions was installed -- django v3.0b and coverage v5.0a7), I then created a simple django model for an app and Test Cases for the model... With the TestCases created, I tried running coverage on my codebase and I get the above error.

The error only occur when I run coverage run manage.py test but other coverage commands worked without any errors...

Don't mind my response if it doesn't meet with what you expected, this is my very first bug report ( with a response ), I'm glad and willing to push the conversation further if need be

@spaceofmiah I'm looking for very specific instructions. Exactly what code did you run? Do you have a GitHub repo I can use? Exactly what commands did you run? Ideally you would literally include "git clone ...." commands and so on.

You can use this github repo https://github.com/spaceofmiah/coverage_report

The instructions/commands to be used are highlighted on the README

Thanks for the instructions, but I'm not seeing the error you are. I had to skip the "pipenv shell" step, because it threw an error, perhaps due to my zsh setup?

Here's what I saw:

@/tmp/bug862 % git clone https://github.com/spaceofmiah/coverage_report.git
Cloning into 'coverage_report'...
remote: Enumerating objects: 63, done.
remote: Counting objects: 100% (63/63), done.
remote: Compressing objects: 100% (44/44), done.
remote: Total 63 (delta 24), reused 46 (delta 17), pack-reused 0
Unpacking objects: 100% (63/63), done.

@/tmp/bug862 % cd coverage_report

@/tmp/bug862/coverage_report master Β± mktmpenv -p python3.6 -n
Running virtualenv with interpreter /usr/local/bin/python3.6
Using base prefix '/usr/local/pythonz/pythons/CPython-3.6.9'
New python executable in /usr/local/virtualenvs/tmp-7b4e391d471e6da1/bin/python3.6
Also creating executable in /usr/local/virtualenvs/tmp-7b4e391d471e6da1/bin/python
Installing setuptools, pip, wheel...done.
Requirement already up-to-date: pip in /usr/local/virtualenvs/tmp-7b4e391d471e6da1/lib/python3.6/site-packages (19.3.1)
Requirement already up-to-date: setuptools in /usr/local/virtualenvs/tmp-7b4e391d471e6da1/lib/python3.6/site-packages (41.4.0)
This is a temporary environment. It will be deleted when you run 'deactivate'.

@/tmp/bug862/coverage_report [tmp-7b4e391d471e6da1] master Β± pip install pipenv
Collecting pipenv
  Using cached https://files.pythonhosted.org/packages/13/b4/3ffa55f77161cff9a5220f162670f7c5eb00df52e00939e203f601b0f579/pipenv-2018.11.26-py3-none-any.whl
Collecting virtualenv-clone>=0.2.5
  Using cached https://files.pythonhosted.org/packages/ba/f8/50c2b7dbc99e05fce5e5b9d9a31f37c988c99acd4e8dedd720b7b8d4011d/virtualenv_clone-0.5.3-py2.py3-none-any.whl
Collecting virtualenv
  Using cached https://files.pythonhosted.org/packages/c5/97/00dd42a0fc41e9016b23f07ec7f657f636cb672fad9cf72b80f8f65c6a46/virtualenv-16.7.7-py2.py3-none-any.whl
Requirement already satisfied: setuptools>=36.2.1 in /usr/local/virtualenvs/tmp-7b4e391d471e6da1/lib/python3.6/site-packages (from pipenv) (41.4.0)
Collecting certifi
  Using cached https://files.pythonhosted.org/packages/18/b0/8146a4f8dd402f60744fa380bc73ca47303cccf8b9190fd16a827281eac2/certifi-2019.9.11-py2.py3-none-any.whl
Requirement already satisfied: pip>=9.0.1 in /usr/local/virtualenvs/tmp-7b4e391d471e6da1/lib/python3.6/site-packages (from pipenv) (19.3.1)
Installing collected packages: virtualenv-clone, virtualenv, certifi, pipenv
Successfully installed certifi-2019.9.11 pipenv-2018.11.26 virtualenv-16.7.7 virtualenv-clone-0.5.3

@/tmp/bug862/coverage_report [tmp-7b4e391d471e6da1] master Β± pipenv install
Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
Installing dependencies from Pipfile.lock (b9e230)…
  🐍   β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰ 5/5 β€” 00:00:07

@/tmp/bug862/coverage_report [tmp-7b4e391d471e6da1] master Β± coverage run manage.py test
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
.
----------------------------------------------------------------------
Ran 1 test in 0.004s

OK
Destroying test database for alias 'default'...

@/tmp/bug862/coverage_report [tmp-7b4e391d471e6da1] master(+0/-0) Β± pipenv run pip list
Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
Package          Version
---------------- ----------
asgiref          3.2.3
certifi          2019.9.11
coverage         5.0a7
Django           3.0b1
pip              19.3.1
pipenv           2018.11.26
pytz             2019.3
setuptools       41.4.0
sqlparse         0.3.0
virtualenv       16.7.7
virtualenv-clone 0.5.3
wheel            0.33.6

This is my workflow and the error log

C:\Users\spaceofmiah\dev\Python\django
Ξ» cd coverage_report\

C:\Users\spaceofmiah\dev\Python\django\coverage_report (master -> origin)
Ξ» pipenv shell
Launching subshell in virtual environment…

C:\Users\spaceofmiah\dev\Python\django\coverage_report (master -> origin)
Ξ» pipenv run pip list
Package    Version
---------- -------
asgiref    3.2.3
coverage   5.0a7
Django     3.0b1
pip        19.2.3
pytz       2019.3
setuptools 41.2.0
sqlparse   0.3.0
wheel      0.33.6

C:\Users\spaceofmiah\dev\Python\django\coverage_report (master -> origin)
Ξ» coverage run manage.py test
Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\core\management\__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\core\management\commands\test.py", line 23, in run_from_argv
    super().run_from_argv(argv)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\core\management\base.py", line 320, in run_from_argv
    parser = self.create_parser(argv[0], argv[1])
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\core\management\base.py", line 294, in create_parser
    self.add_arguments(parser)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\core\management\commands\test.py", line 44, in add_arguments
    test_runner_class = get_runner(settings, self.test_runner)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\test\utils.py", line 301, in get_runner
    test_runner_class = test_runner_class or settings.TEST_RUNNER
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\conf\__init__.py", line 76, in __getattr__
    self._setup(name)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\conf\__init__.py", line 63, in _setup
    self._wrapped = Settings(settings_module)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\conf\__init__.py", line 142, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 936, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'coverage_report'

This is another terminal log for the same project config, source code and everything but with coverage version 4.5 and the test runs perfectly fine

  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'coverage_report'

C:\Users\spaceofmiah\dev\Python\django\coverage_report (master -> origin)
Ξ» pipenv install coverage
Installing coverage…
Adding coverage to Pipfile's [packages]…
Installation Succeeded
Installing dependencies from Pipfile.lock (b9e230)…
  ================================ 5/5 - 00:00:05

C:\Users\spaceofmiah\dev\Python\django\coverage_report (master -> origin)
Ξ» pipenv run pip list
Package    Version
---------- -------
asgiref    3.2.3
coverage   5.0a7
Django     3.0b1
pip        19.2.3
pytz       2019.3
setuptools 41.2.0
sqlparse   0.3.0
wheel      0.33.6

C:\Users\spaceofmiah\dev\Python\django\coverage_report (master -> origin)
Ξ» pipenv install coverage==4.5
Installing coverage==4.5…
Adding coverage to Pipfile's [packages]…
Installation Succeeded
Pipfile.lock (d8e430) out of date, updating to (b9e230)…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Success!
Updated Pipfile.lock (d8e430)!
Installing dependencies from Pipfile.lock (d8e430)…
  ================================ 5/5 - 00:00:04

C:\Users\spaceofmiah\dev\Python\django\coverage_report (master -> origin)
Ξ» pipenv run pip list
Package    Version
---------- -------
asgiref    3.2.3
coverage   4.5
Django     3.0b1
pip        19.2.3
pytz       2019.3
setuptools 41.2.0
sqlparse   0.3.0
wheel      0.33.6

C:\Users\spaceofmiah\dev\Python\django\coverage_report (master -> origin)
Ξ» coverage run manage.py test
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK
Destroying test database for alias 'default'...

I fixed my issue with "pipenv shell" (a bad installation of Jython...), and I still don't see the error. I don't know what could be different between our environments. Can you add this to the top of manage.py:main():

import pprint
pprint.pprint(sys.path)

and see what the difference is between the two versions of coverage.py?

reinstalled coverage 5.0a7 after including to the main method of manage.py file the below scripts

import pprint
pprint.pprint(sys.path)

response from log

pipenv install --pre coverage==5.0a7
Installing coverage==5.0a7…
Adding coverage to Pipfile's [packages]…
Installation Succeeded
Pipfile.lock (b9e230) out of date, updating to (d8e430)…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Success!
Updated Pipfile.lock (b9e230)!
Installing dependencies from Pipfile.lock (b9e230)…
  ================================ 5/5 - 00:00:04



Ξ» pipenv run pip list
Package    Version
---------- -------
asgiref    3.2.3
coverage   5.0a7
Django     3.0b1
pip        19.2.3
pytz       2019.3
setuptools 41.2.0
sqlparse   0.3.0
wheel      0.33.6



C:\Users\spaceofmiah\dev\Python\django\coverage_report (master -> origin)
Ξ» coverage run manage.py test
['C:\\Users\\spaceofmiah\\.virtualenvs\\coverage_report-kFgWHH1O\\Scripts\\coverage.exe',
 'c:\\users\\spaceofmiah\\.virtualenvs\\coverage_report-kfgwhh1o\\scripts\\python36.zip',
 'c:\\users\\spaceofmiah\\.virtualenvs\\coverage_report-kfgwhh1o\\DLLs',
 'c:\\users\\spaceofmiah\\.virtualenvs\\coverage_report-kfgwhh1o\\lib',
 'c:\\users\\spaceofmiah\\.virtualenvs\\coverage_report-kfgwhh1o\\scripts',
 'c:\\users\\spaceofmiah\\appdata\\local\\programs\\python\\python36\\Lib',
 'c:\\users\\spaceofmiah\\appdata\\local\\programs\\python\\python36\\DLLs',
 'c:\\users\\spaceofmiah\\.virtualenvs\\coverage_report-kfgwhh1o',
 'c:\\users\\spaceofmiah\\.virtualenvs\\coverage_report-kfgwhh1o\\lib\\site-packages']
Traceback (most recent call last):
  File "manage.py", line 23, in <module>
    main()
  File "manage.py", line 19, in main
    execute_from_command_line(sys.argv)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\core\management\__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\core\management\commands\test.py", line 23, in run_from_argv
    super().run_from_argv(argv)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\core\management\base.py", line 320, in run_from_argv
    parser = self.create_parser(argv[0], argv[1])
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\core\management\base.py", line 294, in create_parser
    self.add_arguments(parser)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\core\management\commands\test.py", line 44, in add_arguments
    test_runner_class = get_runner(settings, self.test_runner)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\test\utils.py", line 301, in get_runner
    test_runner_class = test_runner_class or settings.TEST_RUNNER
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\conf\__init__.py", line 76, in __getattr__
    self._setup(name)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\conf\__init__.py", line 63, in _setup
    self._wrapped = Settings(settings_module)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\site-packages\django\conf\__init__.py", line 142, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "c:\users\spaceofmiah\.virtualenvs\coverage_report-kfgwhh1o\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 936, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'coverage_report'

log response for coverage version 4.5

Ξ» pipenv install coverage==4.5
Installing coverage==4.5…
Adding coverage to Pipfile's [packages]…
Installation Succeeded
Pipfile.lock (d8e430) out of date, updating to (b9e230)…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Success!
Updated Pipfile.lock (d8e430)!
Installing dependencies from Pipfile.lock (d8e430)…
  ================================ 5/5 - 00:00:05

C:\Users\spaceofmiah\dev\Python\django\coverage_report (master -> origin)
Ξ» coverage run manage.py test
['C:\\Users\\spaceofmiah\\dev\\Python\\django\\coverage_report',
 'c:\\users\\spaceofmiah\\.virtualenvs\\coverage_report-kfgwhh1o\\scripts\\python36.zip',
 'c:\\users\\spaceofmiah\\.virtualenvs\\coverage_report-kfgwhh1o\\DLLs',
 'c:\\users\\spaceofmiah\\.virtualenvs\\coverage_report-kfgwhh1o\\lib',
 'c:\\users\\spaceofmiah\\.virtualenvs\\coverage_report-kfgwhh1o\\scripts',
 'c:\\users\\spaceofmiah\\appdata\\local\\programs\\python\\python36\\Lib',
 'c:\\users\\spaceofmiah\\appdata\\local\\programs\\python\\python36\\DLLs',
 'c:\\users\\spaceofmiah\\.virtualenvs\\coverage_report-kfgwhh1o',
 'c:\\users\\spaceofmiah\\.virtualenvs\\coverage_report-kfgwhh1o\\lib\\site-packages']
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK
Destroying test database for alias 'default'...

What version of Python exactly are you using? What do you see when you type just "python"?

I'm using python 3.6.2
when i type just "python", python interpreter is opened

C:\Users\spaceofmiah\dev\Python\django\jst\coverage_report (master -> origin)
Ξ» python --version
Python 3.6.2

C:\Users\spaceofmiah\dev\Python\django\jst\coverage_report (master -> origin)
Ξ» python
Python 3.6.2 (v3.6.2:5fd33b5, Jul  8 2017, 04:57:36) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

@spaceofmiah did you find a fix for this? I'm also running into a similar issue. Interestingly, the command coverage run manage.py test is successful on Travis CI, but doesn't work locally. Running python manage.py test is successful locally. Repo

@mpbrown Can you give me instructions for reproducing it?

@nedbat After cloning the repo, first run npm run setup and npm run assets to set up the environment using npm scripts. Then npm test to reproduce the ModuleNotFoundError.

Also I should note that the coverage command was previously working correctly even in November.

@mpbrown Thanks, but it's not failing for me. Something fundamental is different on my machine than the other people who can reproduce this. This is what I am seeing:


git log -1

 commit 872a43d298f4f59865aebda310f78f4ea787b986 (HEAD -> master, origin/master, origin/HEAD)
 Author: Mike Brown <[email protected]>
 Date:   Fri Jan 3 10:34:34 2020 -0500

     Add test for ReviewEligibilityView


mktmpenv -p python3.6 -n

Running virtualenv with interpreter /usr/local/bin/python3.6
Using base prefix '/usr/local/pythonz/pythons/CPython-3.6.9'
New python executable in /usr/local/virtualenvs/tmp-d01cca5ee5cb7c10/bin/python3.6
Also creating executable in /usr/local/virtualenvs/tmp-d01cca5ee5cb7c10/bin/python
Installing setuptools, pip, wheel...done.
Requirement already up-to-date: pip in /usr/local/virtualenvs/tmp-d01cca5ee5cb7c10/lib/python3.6/site-packages (19.3.1)
Requirement already up-to-date: setuptools in /usr/local/virtualenvs/tmp-d01cca5ee5cb7c10/lib/python3.6/site-packages (44.0.0)
This is a temporary environment. It will be deleted when you run 'deactivate'.
(tmp-d01cca5ee5cb7c10)


npm run setup

> [email protected] setup /src/foo/bug862/affordable_water
> npm run python-setup && npm install


> [email protected] python-setup /src/foo/bug862/affordable_water
> pip install pipenv && pipenv sync

Collecting pipenv
  Using cached https://files.pythonhosted.org/packages/13/b4/3ffa55f77161cff9a5220f162670f7c5eb00df52e00939e203f601b0f579/pipenv-2018.11.26-py3-none-any.whl
Collecting certifi
  Using cached https://files.pythonhosted.org/packages/b9/63/df50cac98ea0d5b006c55a399c3bf1db9da7b5a24de7890bc9cfd5dd9e99/certifi-2019.11.28-py2.py3-none-any.whl
Collecting virtualenv-clone>=0.2.5
  Using cached https://files.pythonhosted.org/packages/ba/f8/50c2b7dbc99e05fce5e5b9d9a31f37c988c99acd4e8dedd720b7b8d4011d/virtualenv_clone-0.5.3-py2.py3-none-any.whl
Requirement already satisfied: setuptools>=36.2.1 in /usr/local/virtualenvs/tmp-d01cca5ee5cb7c10/lib/python3.6/site-packages (from pipenv) (44.0.0)
Collecting virtualenv
  Using cached https://files.pythonhosted.org/packages/05/f1/2e07e8ca50e047b9cc9ad56cf4291f4e041fa73207d000a095fe478abf84/virtualenv-16.7.9-py2.py3-none-any.whl
Requirement already satisfied: pip>=9.0.1 in /usr/local/virtualenvs/tmp-d01cca5ee5cb7c10/lib/python3.6/site-packages (from pipenv) (19.3.1)
Installing collected packages: certifi, virtualenv-clone, virtualenv, pipenv
Successfully installed certifi-2019.11.28 pipenv-2018.11.26 virtualenv-16.7.9 virtualenv-clone-0.5.3
Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
Installing dependencies from Pipfile.lock (9e2090)…
Ignoring atomicwrites: markers 'sys_platform == "win32"' don't match your environment
Ignoring colorama: markers 'sys_platform == "win32"' don't match your environment
  🐍   β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰ 40/40 β€” 00:02:42
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
All dependencies are now up-to-date!
npm WARN The package gulp is included as both a dev and production dependency.

audited 8256 packages in 2.833s
found 0 vulnerabilities


npm run assets

> [email protected] assets /src/foo/bug862/affordable_water
> npm run gulp && npm run collectstatic && npm run compress


> [email protected] gulp /src/foo/bug862/affordable_water
> pipenv run gulp

Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
[11:14:14] Using gulpfile /src/foo/bug862/affordable_water/gulpfile.js
[11:14:14] Starting 'default'...
[11:14:14] Starting 'bourbon'...
[11:14:14] Finished 'bourbon' after 129 ms
[11:14:14] Starting 'normalize'...
[11:14:15] Finished 'normalize' after 21 ms
[11:14:15] Starting 'neat'...
[11:14:15] Finished 'neat' after 84 ms
[11:14:15] Finished 'default' after 238 ms

> [email protected] collectstatic /src/foo/bug862/affordable_water
> pipenv run python manage.py collectstatic --noinput

Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.

119 static files copied to '/src/foo/bug862/affordable_water/staticfiles', 264 unmodified, 564 post-processed.

> [email protected] compress /src/foo/bug862/affordable_water
> pipenv run python manage.py compress

Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
Compressing... done
Compressed 1 block(s) from 34 template(s) for 0 context(s).


npm test

> [email protected] test /src/foo/bug862/affordable_water
> pipenv run python manage.py test

Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
.................................................................................
----------------------------------------------------------------------
Ran 81 tests in 8.491s

OK
Destroying test database for alias 'default'...

Same problem here.
Python 3.6.8 [MSC v.1916 64 bit (AMD64)] on win32
No Problem with coverage==4.5.4
Fail with coverage==5.0.2
When I look at this thread, I see that @spaceofmiah runs Windows but @nedbat does not.
@mpbrown, do you use Windows too ?

Same thing as above but with Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)] on win32

Seems to be windows issue since I don't get the ModuleNotFoundError with linux vagrant box. Coverage 4.5.4 is fine though.

Same, using coverage==5.0.2. Like others, coverage 4.5.4 works. Python is:

Python 3.6.1 (default, Jun 14 2017, 18:29:17) 
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)] on darwin

Whereas the other reports seem to be WIndows, I'm on macOS Catalina. uname -a:

Darwin bluebell.local 19.2.0 Darwin Kernel Version 19.2.0: Sat Nov  9 03:47:04 PST 2019; root:xnu-6153.61.1~20/RELEASE_X86_64 x86_64

To reproduce in my environment:

# I don't think it matters that I use pyenv. Create the virtualenv however you want.
pyenv virtualenv coveragepy
pyenv activate coveragepy

pip install coverage==5.0.2 Django==3.0
django-admin startproject coveragepytest
cd coveragepytest

coverage run --source coveragepytest manage.py test
# Can also try `coverage run --source='.' manage.py test`, etc.

Outputs:

Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/Users/james/.pyenv/versions/3.6.1/envs/coveragepy/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/Users/james/.pyenv/versions/3.6.1/envs/coveragepy/lib/python3.6/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/james/.pyenv/versions/3.6.1/envs/coveragepy/lib/python3.6/site-packages/django/core/management/commands/test.py", line 23, in run_from_argv
    super().run_from_argv(argv)
  File "/Users/james/.pyenv/versions/3.6.1/envs/coveragepy/lib/python3.6/site-packages/django/core/management/base.py", line 320, in run_from_argv
    parser = self.create_parser(argv[0], argv[1])
  File "/Users/james/.pyenv/versions/3.6.1/envs/coveragepy/lib/python3.6/site-packages/django/core/management/base.py", line 294, in create_parser
    self.add_arguments(parser)
  File "/Users/james/.pyenv/versions/3.6.1/envs/coveragepy/lib/python3.6/site-packages/django/core/management/commands/test.py", line 44, in add_arguments
    test_runner_class = get_runner(settings, self.test_runner)
  File "/Users/james/.pyenv/versions/3.6.1/envs/coveragepy/lib/python3.6/site-packages/django/test/utils.py", line 301, in get_runner
    test_runner_class = test_runner_class or settings.TEST_RUNNER
  File "/Users/james/.pyenv/versions/3.6.1/envs/coveragepy/lib/python3.6/site-packages/django/conf/__init__.py", line 76, in __getattr__
    self._setup(name)
  File "/Users/james/.pyenv/versions/3.6.1/envs/coveragepy/lib/python3.6/site-packages/django/conf/__init__.py", line 63, in _setup
    self._wrapped = Settings(settings_module)
  File "/Users/james/.pyenv/versions/3.6.1/envs/coveragepy/lib/python3.6/site-packages/django/conf/__init__.py", line 142, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/Users/james/.pyenv/versions/3.6.1/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 936, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'coveragepytest'
Coverage.py warning: No data was collected. (no-data-collected)
Alex@TOXIN C:\devel
$ py -3.6 -m venv env

Alex@TOXIN C:\devel
$ .\env\Scripts\activate

(env) Alex@TOXIN C:\devel
$ pip install coverage==5.0.2 Django==3.0
Collecting coverage==5.0.2
  Downloading https://files.pythonhosted.org/packages/06/77/2e947dadbdf9d3fb37af05f3ba9a246ff1161cde5e82f802b8d9ed7b832a/coverage-5.0.2-cp36-cp36m-win_amd64.whl (205kB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 215kB 4.9MB/s
Collecting Django==3.0
  Downloading https://files.pythonhosted.org/packages/43/d6/0aed0b12c66527748ce5a007da4618a65dfbe1f8fca82eccedf57d60295f/Django-3.0-py3-none-any.whl (7.4MB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 7.4MB 3.4MB/s
Collecting pytz (from Django==3.0)
  Downloading https://files.pythonhosted.org/packages/e7/f9/f0b53f88060247251bf481fa6ea62cd0d25bf1b11a87888e53ce5b7c8ad2/pytz-2019.3-py2.py3-none-any.whl (509kB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 512kB 8.5MB/s
Collecting sqlparse>=0.2.2 (from Django==3.0)
  Downloading https://files.pythonhosted.org/packages/ef/53/900f7d2a54557c6a37886585a91336520e5539e3ae2423ff1102daf4f3a7/sqlparse-0.3.0-py2.py3-none-any.whl
Collecting asgiref~=3.2 (from Django==3.0)
  Downloading https://files.pythonhosted.org/packages/a5/cb/5a235b605a9753ebcb2730c75e610fb51c8cab3f01230080a8229fa36adb/asgiref-3.2.3-py2.py3-none-any.whl
Installing collected packages: coverage, pytz, sqlparse, asgiref, Django
Successfully installed Django-3.0 asgiref-3.2.3 coverage-5.0.2 pytz-2019.3 sqlparse-0.3.0
You are using pip version 18.1, however version 19.3.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

(env) Alex@TOXIN C:\devel
$ django-admin startproject coveragepytest

(env) Alex@TOXIN C:\devel
$ cd coveragepytest\

(env) Alex@TOXIN C:\devel\coveragepytest
$ coverage run --source coveragepytest manage.py test
Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "c:\devel\env\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "c:\devel\env\lib\site-packages\django\core\management\__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "c:\devel\env\lib\site-packages\django\core\management\commands\test.py", line 23, in run_from_argv
    super().run_from_argv(argv)
  File "c:\devel\env\lib\site-packages\django\core\management\base.py", line 320, in run_from_argv
    parser = self.create_parser(argv[0], argv[1])
  File "c:\devel\env\lib\site-packages\django\core\management\base.py", line 294, in create_parser
    self.add_arguments(parser)
  File "c:\devel\env\lib\site-packages\django\core\management\commands\test.py", line 44, in add_arguments
    test_runner_class = get_runner(settings, self.test_runner)
  File "c:\devel\env\lib\site-packages\django\test\utils.py", line 301, in get_runner
    test_runner_class = test_runner_class or settings.TEST_RUNNER
  File "c:\devel\env\lib\site-packages\django\conf\__init__.py", line 76, in __getattr__
    self._setup(name)
  File "c:\devel\env\lib\site-packages\django\conf\__init__.py", line 63, in _setup
    self._wrapped = Settings(settings_module)
  File "c:\devel\env\lib\site-packages\django\conf\__init__.py", line 142, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "C:\Program Files\Python36\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'coveragepytest'
Coverage.py warning: No data was collected. (no-data-collected)

(env) Alex@TOXIN C:\devel\coveragepytest
$ dir
 Volume in drive C has no label.
 Volume Serial Number is B6EF-7E7F

 Directory of C:\devel\coveragepytest

01/08/2020  05:59 AM    <DIR>          .
01/08/2020  05:59 AM    <DIR>          ..
01/08/2020  05:59 AM            53,248 .coverage
01/08/2020  05:59 AM    <DIR>          coveragepytest
01/08/2020  05:59 AM               655 manage.py
               2 File(s)         53,903 bytes
               3 Dir(s)  85,808,148,480 bytes free

(env) Alex@TOXIN C:\devel\coveragepytest
$ dir coveragepytest\
 Volume in drive C has no label.
 Volume Serial Number is B6EF-7E7F

 Directory of C:\devel\coveragepytest\coveragepytest

01/08/2020  05:59 AM    <DIR>          .
01/08/2020  05:59 AM    <DIR>          ..
01/08/2020  05:59 AM               421 asgi.py
01/08/2020  05:59 AM             3,230 settings.py
01/08/2020  05:59 AM               777 urls.py
01/08/2020  05:59 AM               421 wsgi.py
01/08/2020  05:59 AM                 0 __init__.py
               5 File(s)          4,849 bytes
               2 Dir(s)  85,808,132,096 bytes free

(env) Alex@TOXIN C:\devel\coveragepytest
$

@jpmckinney Thanks, I was finally able to reproduce it myself. Ironically, this turned out to be the important bit:

```

I don't think it matters that I use pyenv. Create the virtualenv however you want.

pyenv virtualenv coveragepy
pyenv activate coveragepy

It wasn't until I used pyenv and pyenv-virtualenv that the problem appeared for me. Now to work on a fix....

For those facing this problem: a work-around seems to be to use "python -m coverage run (etc)" instead of "coverage run (etc)".

Hi there, I am running into this error on Windows (but not Mac/Linux), when upgrading from coverage 4.5.4 to 5.0.2. I call coverage run test.py from tox and get the error:

Traceback (most recent call last):
  File "test.py", line 18, in <module>
    from tests.coloredtestrunner import ColoredTestRunner, ColoredTestResult
ImportError: No module named 'tests'

tox, and therefore coverage, is called from the project root directory, where test.py and the tests module are. Thanks for the workaround -- that works.

To try to help debug this error though:

Using coverage 4.5.4, printing sys.path from test.py yields:

['C:\\Users\\Ryan\\Documents\\NWB\\hdmf',
 'c:\\users\\ryan\\documents\\nwb\\hdmf\\.tox\\coverage-py35\\scripts\\python35.zip',
 ...']

Keeping everything else the same, except for telling tox to use coverage==5.0.2, printing sys.path from test.py yields:

['C:\\Users\\Ryan\\Documents\\NWB\\hdmf\\.tox\\coverage-py35\\Scripts\\coverage.EXE',
 'c:\\users\\ryan\\documents\\nwb\\hdmf\\.tox\\coverage-py35\\scripts\\python35.zip',
 ...']

The only difference between the two is that the first entry has been replaced with the path to coverage.exe. So test.py cannot be found.

But why does this error happen only on Windows? I suspect that these lines are the root cause:
https://github.com/nedbat/coveragepy/blob/b7e0eec3d794ee350f8a4392a0c9cc90fff54fa0/coverage/execfile.py#L164-L167
os.path.abspath(sys.path[0]) should be 'C:\\Users\\Ryan\\Documents\\NWB\\hdmf' in my use case, and os.path.abspath(os.path.dirname(top_file)) _might be_ 'c:\\users\\ryan\\documents\\nwb\\hdmf', and so the == comparison fails and sys.path[0] is overridden. I would guess this is not an issue on Mac/Linux because they handle path case differently. I would try normalizing the case of the paths or getting the paths with the correct case. I can't easily test this idea myself, but maybe this helps with a fix.

The root of the problem on windows is that distlib creates a zipapp for the launcher now, and zipapps dont put cwd on sys.path. if you run python -m coverage, you shouldn't run into the problem.

Sent from my MetroPCS 4G LTE Android Device
Get Outlook for Androidhttps://aka.ms/ghei36


From: Ryan Ly notifications@github.com
Sent: Thursday, January 9, 2020 7:10:29 PM
To: nedbat/coveragepy coveragepy@noreply.github.com
Cc: Alexander Walters tritium@sdamon.com; Comment comment@noreply.github.com
Subject: Re: [nedbat/coveragepy] ModuleNotFoundError: No module named 'django_project' when I used coverage run manage.py test (#862)

Hi there, I am running into this error on Windows (but not Mac/Linux), when upgrading from coverage 4.5.4 to 5.0.2. I call coverage run test.py from tox and get the error:

Traceback (most recent call last):
File "test.py", line 18, in
from tests.coloredtestrunner import ColoredTestRunner, ColoredTestResult
ImportError: No module named 'tests'

tox, and therefore coverage, is called from the project root directory, where test.py and the tests module are. Thanks for the workaround -- that works.

To try to help debug this error though:

Using coverage 4.5.4, printing sys.path from test.py yields:

['C:\Users\Ryan\Documents\NWB\hdmf',
'c:\users\ryan\documents\nwb\hdmf\.tox\coverage-py35\scripts\python35.zip',
...']

Keeping everything else the same, except for telling tox to use coverage==5.0.2, printing sys.path from test.py yields:

['C:\Users\Ryan\Documents\NWB\hdmf\.tox\coverage-py35\Scripts\coverage.EXE',
'c:\users\ryan\documents\nwb\hdmf\.tox\coverage-py35\scripts\python35.zip',
...']

The only difference between the two is that the first entry has been replaced with the path to coverage.exe. So test.py cannot be found.

But why does this error happen only on Windows? I suspect that these lines are the root cause:
https://github.com/nedbat/coveragepy/blob/b7e0eec3d794ee350f8a4392a0c9cc90fff54fa0/coverage/execfile.py#L164-L167
os.path.abspath(sys.path[0]) should be 'C:\Users\Ryan\Documents\NWB\hdmf' in my use case, and os.path.abspath(os.path.dirname(top_file)) might be 'c:\users\ryan\documents\nwb\hdmf', and so the == comparison fails and sys.path[0] is overridden. I would guess this is not an issue on Mac/Linux because they handle path case differently. I would try normalizing the case of the paths or getting the paths with the correct case. I can't easily test this idea myself, but maybe this helps with a fix.

β€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com/nedbat/coveragepy/issues/862?email_source=notifications&email_token=AANS6U4I2VSJ5DIP3X3CMODQ464HLA5CNFSM4JEOVUV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEISHJMI#issuecomment-572814513, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AANS6UZEJGC6QNGHSQ3ESNDQ464HLANCNFSM4JEOVUVQ.

Ah, thanks! Never mind my speculation then! :)

Not sure if this is the same problem: https://github.com/psf/black/pull/1227.

Black runs coverage run tests/test_black.py on GitHub Actions for Python 3.6, 3.7 and 3.8 on Ubuntu, macOS and Windows.

For some reason, the new Coverage.py version 5 is failing on Windows for Python 3.6 and 3.7.

Run coverage run tests/test_black.py
Traceback (most recent call last):
  File "tests/test_black.py", line 1788, in <module>
    unittest.main(module="test_black")
  File "c:\hostedtoolcache\windows\python\3.6.8\x64\lib\unittest\main.py", line 64, in __init__
    self.module = __import__(module)
ModuleNotFoundError: No module named 'test_black'
##[error]Process completed with exit code 1.

It's passing on Windows for 3.8, and all Python versions on Ubuntu and macOS.

Here's an older build that passed for everything, before Coverage.py 5 came out:

Pinning to coverage<5 for 3.6-3.7 on Windows is a workaround.

I have what I think is a fix for this problem. If people could try it and let me know, that would be a huge help:

pip install git+https://github.com/nedbat/coveragepy@nedbat/fix-862#egg=coverage==0.0

/cc @hugovk @tritium21 @rly @jpmckinney @spaceofmiah @Temeez @mpbrown @obi-jerome

@hugovk Thanks! Any other people with data points?

@nedbat That fixed it! Thanks!!

This is now available in 5.0.3: https://pypi.org/project/coverage/5.0.3/

Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Python\Python37\lib\threading.py", line 926, in _bootstrap_inner
self.run()
File "C:\Python\Python37\lib\threading.py", line 870, in run
self._target(self._args, *self._kwargs)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\utils\autoreload.py", line 53, in wrapper
fn(args, *kwargs)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\core\management\commandsrunserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\utils\autoreload.py", line 76, in raise_last_exception
raise _exception[1]
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\core\management__init__.py", line 357, in execute
autoreload.check_errors(django.setup)()
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\utils\autoreload.py", line 53, in wrapper
fn(args, *kwargs)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\apps\config.py", line 116, in create
mod = import_module(mod_path)
File "C:\Python\Python37\lib\importlib__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 953, in _find_and_load_unlocked
File "", line 219, in _call_with_frames_removed
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'Testdjango'

Traceback (most recent call last):
File "manage.py", line 21, in
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\core\management__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\core\management__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\core\management\base.py", line 328, in run_from_argv
self.execute(args, cmd_options)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\core\management\commandsrunserver.py", line 60, in execute
super().execute(
args, *options)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\core\management\base.py", line 369, in execute
output = self.handle(
args, *options)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\core\management\commandsrunserver.py", line 95, in handle
self.run(
options)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\core\management\commandsrunserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, *
options)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\utils\autoreload.py", line 599, in run_with_reloader
start_django(reloader, main_func, args, *kwargs)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\utils\autoreload.py", line 584, in start_django
reloader.run(django_main_thread)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\utils\autoreload.py", line 299, in run
self.run_loop()
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\utils\autoreload.py", line 305, in run_loop
next(ticker)
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\utils\autoreload.py", line 345, in tick
for filepath, mtime in self.snapshot_files():
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\utils\autoreload.py", line 361, in snapshot_files
for file in self.watched_files():
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\utils\autoreload.py", line 260, in watched_files
yield from iter_all_python_module_files()
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\utils\autoreload.py", line 105, in iter_all_python_module_files
return iter_modules_and_files(modules, frozenset(_error_files))
File "C:\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\utils\autoreload.py", line 141, in iter_modules_and_files
resolved_path = path.resolve(strict=True).absolute()
File "C:\Python\Python37\lib\pathlib.py", line 1161, in resolve
s = self._flavour.resolve(self, strict=strict)
File "C:\Python\Python37\lib\pathlib.py", line 200, in resolve
return self._ext_to_normal(_getfinalpathname(s))
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: ''

I am getting below error. Please help me in this regard. I am using python 3.7. Django 3.0.4. Please do let me know if you need more details

Hey @Ravi9562 we have same problem, please tell me if u have done with this problem. i really" help

@Ravi9562 @jericore it sounds like you are having an issue with Django. This page is for issues with a different package, coveragepy, not Django. For help with Django, please consult the official Django help page or post your question on StackOverflow. Good luck!

I was into same error for me it was just because of running in a lot of errors i just unintentionally did some typo or changed the app name in Procfile and now it works fine.

For those facing this problem: a work-around seems to be to use "python -m coverage run (etc)" instead of "coverage run (etc)".

A great solution for running coverage on Local.

Was this page helpful?
0 / 5 - 0 ratings