0

I am trying to run a tests file in a Django project, the app is called jira and project jiraglean , test file is tests.py

I run the test with:

jiraglean test jira.tests --settings=core.settings.test  

Which causes this error:

File "/Users/pavel/.pyenv/versions/3.8.2/lib/python3.8/runpy.py", line 86, in 
_run_code
File "/Users/pavel/.pyenv/versions/3.8.2/lib/python3.8/multiprocessing/context.py", 
line 57, in Manager
exec(code, run_globals)
File "/Users/pavel/Library/Caches/pypoetry/virtualenvs/jiraglean-VXquq6c2- 
py3.8/bin/jiraglean", line 2, in <module>
from jiraglue.jiraglue import run
ModuleNotFoundError: No module named 'jiraglean.jiraglean'; 'jiraglean' is not a 
package

I am in a poetry virtual env when doing this. Path to project binary is correct /bin/jiraglean. Test runner instantiates. I just do not understand this error.

Relevant files/folders.

jiraglean                                         
├─ core                                           
│  ├─ management                                           
│  ├─ permissions                                        
│  ├─ settings                              
│  │  ├─ __init__.py                    
│  │  ├─ base.py                        
│  │  ├─ ci.py                          
│  │  ├─ dev.py                                              
│  │  └─ test.py                        
│  ├─ __init__.py                       
│  ├─ api.py                                                      
│  ├─ pagination.py                     
│  ├─ serializers.py                    
│  ├─ urls.py                           
│  ├─ utils.py                          
│  └─ wsgi.py                           
├─ jira                                   
│  ├─ __init__.py                       
│  ├─ admin.py                          
│  ├─ api.py                            
│  ├─ apps.py                           
│  ├─ models.py                         
│  ├─ serializers.py                    
│  ├─ tests.py                                                 
│  └─ views.py 

            

UPDATE: Project is run at root with following, hence no manage.py -

def main():
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings.dev")
    try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
        "Couldn't import Django. Are you sure it's installed and "
        "available on your PYTHONPATH environment variable? Did you "
        "forget to activate a virtual environment?"
    ) from exc
    execute_from_command_line(sys.argv)



                                                     
godhar
  • 1,128
  • 1
  • 14
  • 34

1 Answers1

0

This is the solution that you were probably searching for running a test of a specific app:

Previous Stack Overflow solution

python manage.py test example.tests.A.test_a

I would also suggest consulting the documentation

Gledi
  • 51
  • 1
  • I don't have a `manage.py`. – godhar Jan 21 '22 at 14:31
  • What do you mean you don't have a manage.py in Django? How did you initialize the project? What command are you running to run the server? – Gledi Jan 22 '22 at 11:24
  • I didn't create this project, otherwise, I would not be asking. You don't have to have a manage.py, e.g this [article](https://lincolnloop.com/blog/goodbye-managepy/). I updated the answer with how I believe it is being run. Other observations are that my `test.py` has bad config. Running without that flag works. But I am not sure why. – godhar Jan 24 '22 at 12:12
  • Thank you for giving more details to your question. I was kinda lost initially. But from what i can see running the project without a manage.py would also affect different paths that are by default recognized by the Django Environment . So i would try looking up to the different paths requested once you put the flags. That's the only issue I see , as by your error message. – Gledi Jan 25 '22 at 13:08