I'm upgrading a Django app from version 1.10.7 to 1.11.2.
After the upgrade, runserver command works well, but when I try to run the unit test suite the following error raised:
CommandError: Option `--functions=...` couldn't be empty
To run the unit test suite, I'm using the following command:
python src\main\manage.py test --noinput
As you can see, I'm not using any --function parameter and this is the same command that I used before the upgrade.
I reach the same situation if I run the test suite specifying the file to run.
I have also tried to run the help function for the manage command and no --functions parameter is showed.
I'm a little bit confused on this issue, and I don't find any information about this error in both, documentation and release notes.
Anyone knows how this error is raised and how to fix it?
I'm running Django 1.11.2 and Python 2.7
Thanks in advance
It looks like you've got a custom management command called check that conflicts with one of Django's built-in commands. For whatever reason, manage.py test is calling your custom command instead of the built-in one.
Renaming your custom command to something that doesn't conflict should solve the problem.
Related
I'm running the command
make config=default_config.mk task
with task being different tasks I can run. The entire program is pretty dated with very little support. The 'default_config.mk' file lets you change directorys, after that the programm is supposed to work.
It turns out the makefile runs the default-python. The Makefile basically runs a bunch of different .py-files.
I've already created an alias for python3 which works in the terminal, but not when I run the program. I've now created a new Makerun-file and changed every python to python3. Apart from that and adding '#!/bin/bash' to the first line (to make it executable?) it should be the same file.
Now, I keep getting the error
make: *** No rule to make target `task'. Stop.
Does anyone have an idea?
Thank you
Edit:
So I've managed to install Psycopg2 to Python 2.7, now it throws an error for the command:
python SciGRID.py --dbpwrd $(postgres_password)
Error:
SciGRID.py: error: --dbpwrd option requires an argument
The Programm is supposed to run on Python 2.7. I think the best way would be to change the Makefile, but that's when the error "no rule..." appears. If I use the default Makefile I basically keep running into errors as its pretty dated. Why is it not accepting the edited makefile?
I have the following problem :
I am doing some unit tests but the problem is that I cannot use the debugger I tried to click on "Debug namefile" using a breakpoint but it does not work. Alternatively, I tried to use tyhe following decorator #override_settings(DEBUG=True) but once again I had no result using this way.
I precise that it is only with unit tests I have this kind of problems. The other part of the code works well.
Could you help me please ?
PS: to do the unit test I imported TestCase from django.test.
Thank you very much !
I used to have same problem with PyCharm+Django when running python manage.py test from command line. I solved it by creating new configuration for test.
Mainly, you will need to fill "Script path" (path to manage.py) and "Parameters".
Then, run debug with that configuration and breakpoints in Django tests will work.
PyCharm menu:
Run / Edit configuration / Add Django test / Add Target and options.
For example, here is a mapping from command line to GUI fields,
Run just one test method
./manage.py test --keepdb animals.tests.AnimalTestCase.test_animals_can_speak
Target: animals.tests.AnimalTestCase.test_animals_can_speak
options: --keepdb
.
Ref, https://www.jetbrains.com/help/pycharm/2020.1/run-debug-configuration-django-test.html
I am trying to run unit test in pycharm but not seeing an option in the context menu..
Please find as show below
Please help
Also, when I run from the following command from the console, 'python -m unittest login.py' unit test are running but again if I run command 'python login.py' actual test execution is not running.
How to run unit test and test execution from console or from pycharm IDE ..??
Looks like you have an existed run configuration (login) for this script so PyCharm suggests it instead of running tests. Either remove it from Run | Edit configurations and try to right-click -> Run unittest or use Run | Run... and select unittest there. Has it helped?
Thank you Pavel for respond, I have solved by renaming file name starts with 'test', it worked now, not sure if this is really the way to fix but it resolve my problem.
In a Django project, it is possible to create unit-tests to verify what we had done so far. The principle is simple. We have to execute the command python3 manage.py test in the shell. When an error is detected in the program, the shell will display it and stop the process. However, the procedure has a little gap. If we have several errors, we have to correct it and restart the whole process. This process could take several minutes which depends of our program. Is there a manner to restart the process where the error has been detected instead of restart the whole procedure?
EDIT :
In fact, another problem I have is to retain the databases instead of recreate it. How could I do such thing?
If you want to automatically run only failing tests you need to use a third party testing driver like Nose or create your own. But it's not worth it because ...
You can specify particular tests to run by supplying any number of
“test labels” to ./manage.py test. Each test label can be a full
Python dotted path to a package, module, TestCase subclass, or test
method. For instance:
# Run just one test method
$ ./manage.py test animals.tests.AnimalTestCase.test_animals_can_speak
Source: https://docs.djangoproject.com/en/1.10/topics/testing/overview/
This approach can be used to re run only the ones that have failed.
Please note that third party test runners will probably recreate the database every time you run the test - even for only the failing test. On the other hand the django default test runner has the --keep option which allows the database to be reused. For more details see: https://stackoverflow.com/a/37100979/267540
I want to run my unit tests for a Python Google App Engine project using
Run As => Python unit-test
But when I try that all my Model tests bail with the error message:
BadArgumentError: app must not be empty.
Anyone got this to work?
NB: The tests runs fine using Nose --with-gae. But I want the PyDev integration with hyperlinking of resources and such.
Pasting the answer I got from the Fabioz (the PyDev creator) himself over at the PyDev forums on SF: https://sourceforge.net/projects/pydev/forums/forum/293649/topic/3618848
There's no such option right now... please enter a feature request for that. Note that you can run nose itself from inside of pydev (with the --with-gae option) -- which at least would give you hyperlinking inside of pydev -- to do that just create a custom run where nose is the main script.
Indeed, that's what I did and it works as advertised. I also entered that feature request. You can help by pushing your support behind the request: https://sourceforge.net/tracker/?func=detail&aid=2974043&group_id=85796&atid=577332