How to run django test on google cloud platform - python

i'm deploying my app on Google Cloud platform. Every thing seems to be set up correctly but when i try to launch test, i get this error :
======================================================================
ERROR: purbeurre.core (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: purbeurre.core
Traceback (most recent call last):
File "/usr/lib/python3.6/unittest/loader.py", line 462, in _find_test_path
package = self._get_module_from_name(name)
File "/usr/lib/python3.6/unittest/loader.py", line 369, in _get_module_from_name
__import__(name)
ModuleNotFoundError: No module named 'purbeurre.core'
Is there a special setting to have all my test modules loaded ?
i did check locally and it's working on my dev environnement

It appear that i have an init.py file at root level of my project and it's messing up with unittest.
After deleting this init.py file the test is launched properly

Related

Visual Studio Code ModuleNotFoundError: No module named '_overlapped'

I have developed the following message when running flask. I attempted to add overlapped, via pip install overlap. I can't find answers to this. This is my terminal output. Can someone please help?
dvdjms#DESKTOP-OPG4GRH:/mnt/c/Users/dvdjm/Documents/CS50/project$ flask run
Usage: flask run [OPTIONS]
Try 'flask run --help' for help.
Error: While importing 'app', an ImportError was raised:
Traceback (most recent call last):
File "/home/dvdjms/.local/lib/python3.8/site-packages/flask/cli.py", line 218, in locate_app
__import__(module_name)
File "/mnt/c/Users/dvdjm/Documents/CS50/project/app.py", line 1, in <module>
from asyncio.windows_events import NULL
File "/usr/lib/python3.8/asyncio/windows_events.py", line 3, in <module>
import _overlapped
ModuleNotFoundError: No module named '_overlapped'
Did you mean to import NULL from asyncio.windows_event? I'm guessing it was automatically imported by your IDE, None is likely what you're looking for instead of NULL, which isn't a keyword in Python.

error when running flask - no module with name '_crypt'

i have a problem running flask. It started fine until I loaded a simple login form.
when running flask via gitbash, I get an error like this
flask run
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
Usage: flask run [OPTIONS]
Try 'flask run --help' for help.
Error: While importing 'app', an ImportError was raised:
Traceback (most recent call last):
File "C:\Users\****\AppData\Local\Programs\Python\Python39\lib\crypt.py", line 6, in <module>
import _crypt
ModuleNotFoundError: No module named '_crypt'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\****\AppData\Local\Programs\Python\Python39\lib\site-packages\flask\cli.py", line 234, in locate_app
__import__(module_name)
File "E:\Program Files\xampp\htdocs\****\app.py", line 2, in <module>
from crypt import methods
File "C:\Users\****\AppData\Local\Programs\Python\Python39\lib\crypt.py", line 9, in <module>
raise ImportError("The crypt module is not supported on Windows")
ImportError: The crypt module is not supported on Windows
btw, i used windows
remove this from the top of the file:
from crypt import methods
it should work again. At least it did for me. VSCode may have autogenerated this for you.
This thing occur most times with auto-import in vs code.
If you inspect your code critically, you'd notice that your vs-code editor has automatically included the line of code from crypt import methods above your imports.
Just comment or delete it out and try re-running your app again, you'd be in good shape.

For what reason would a Flask application run fine, but fail to load a module in the unittest?

So, I created a small flask API. Basically a wrapper for another API.
I used requests-futures to send multiple calls asynchronously.
I set up my virtual environment. Everything works exactly as I intend. However, when I try to run some tests I've written (using python -m unittest) this is the error I get:
======================================================================
ERROR: test (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: test
Traceback (most recent call last):
File "/usr/lib/python3.8/unittest/loader.py", line 436, in _find_test_path
module = self._get_module_from_name(name)
File "/usr/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name
__import__(name)
File "/home/cwverica/take-home-apps/quixr/test.py", line 2, in <module>
from app import app, session
File "/home/cwverica/take-home-apps/quixr/app.py", line 3, in <module>
from requests_futures.sessions import FuturesSession
ModuleNotFoundError: No module named 'requests_futures'
I have reinstalled the module using pip. I made sure to pip freeze > requirements.txt just in case it was reading module availability from there. But all in all I'm stumped. If anyone could help me out here, I'd greatly appreciate it.

No module named appengine.ext for get client lib java create

I want to create get client lib java and when i run this code
sudo python lib/endpoints/endpointscfg.py get_client_lib java -bs gradle src.service.moDbile_api.MobileApi
it gave me an error
valid SDK root.
Traceback (most recent call last):
File "lib/endpoints/endpointscfg.py", line 59, in <module>
import _endpointscfg_setup # pylint: disable=unused-import
File "/var/www/html/salesmanagement/SalesManagement/lib/endpoints/_endpointscfg_setup.py", line 107, in <module>
_SetupPaths()
File "/var/www/html/salesmanagement/SalesManagement/lib/endpoints/_endpointscfg_setup.py", line 103, in _SetupPaths
from google.appengine.ext import vendor
ImportError: No module named appengine.ext
The google.appengine.ext module only exists when running your script in the App Engine First Generation (Python 2.7) runtime.

Python unittest fails to load modules when executed from command line

When I try to run python unittest from command line, in windows, I get the following error:
test_validateXml (unittest.loader.ModuleImportFailure) ... ERROR
consequently in the details there is an error message that reads:
Traceback (most recent call last):
File "C:\Python27\lib\unittest\loader.py", line 254, in _find_tests
module = self._get_module_from_name(name)
File "C:\Python27\lib\unittest\loader.py", line 232, in _get_module_from_name
__import__(name)
from application.helpers.fileHelper import FileIO as fileIO
ImportError: No module named application.helpers.fileHelper
The command I'm running is:
python -m unittest discover -v -p "*est*.py"
As I understand the reading I've done, all that's required in order to import modules is an __init__.py file in every directory of the project, which I have.
When I run the test from Visual Studio they run without any problems, any help is appreciated thanks.

Categories

Resources