django-nose

Django test coverage vs code coverage

懵懂的女人 提交于 2019-12-03 01:11:16
I've successfully installed and configured django-nose with coverage Problem is that if I just run coverage for ./manage.py shell and exit out of that shell - it shows me 37% code coverage. I fully understand that executed code doesn't mean tested code. My only question is -- what now? What I'm envisioning is being able to import all the python modules and "settle down" before executing any tests, and directly communicating with coverage saying "Ok, start counting reached code here." Ideally this would be done by nose essentially resetting the "touched" lines of code right before executing

How do I tell django-nose where my tests are?

南笙酒味 提交于 2019-12-02 21:58:34
I have my tests for a Django application in a tests directory: my_project/apps/my_app/ ├── __init__.py ├── tests │ ├── __init__.py │ ├── field_tests.py │ └── storage_tests.py ├── urls.py ├── utils.py └── views.py The Django test runner requires that I put a suite() function in the __init__.py file of my application's tests directory. That function returns the test cases that will run when I do $ python manage.py test I installed django-nose. When I try to run the tests with django-nose, 0 tests are run: $ python manage.py test <app_name> If I point directly at the test module, the tests are

Django ORM - mock values().filter() chain

我是研究僧i 提交于 2019-11-30 17:39:43
I am trying to mock a chained call on the Djangos model.Manager() class. For now I want to mock the values() and filter() method. To test that I created a little test project: Create a virtual environment Run pip install django mock mock-django nose django-nose Create a project django-admin.py startproject mocktest Create an app manage.py startapp mockme Add django_nose and mocktest.mockme to INSTALLED_APPS (settings.py) Add TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' to settings.py To verfiy that everything is setup correctly I ran manage.py test . One test is run, the standard test

How to test coverage properly with Django + Nose

陌路散爱 提交于 2019-11-30 13:14:36
问题 Currently have a project configured to run coverage via Django's manage command like so: ./manage.py test --with-coverage --cover-package=notify --cover-branches --cover-inclusive --cover-erase This results in a report like the following: Name Stmts Miss Branch BrMiss Cover Missing -------------------------------------------------------------------------- notify.decorators 4 1 0 0 75% 4 notify.handlers 6 1 2 0 88% 11 notify.notification_types 46 39 2 0 19% 8-55, 59, 62, 66 notify

Django ORM - mock values().filter() chain

荒凉一梦 提交于 2019-11-30 02:05:04
问题 I am trying to mock a chained call on the Djangos model.Manager() class. For now I want to mock the values() and filter() method. To test that I created a little test project: Create a virtual environment Run pip install django mock mock-django nose django-nose Create a project django-admin.py startproject mocktest Create an app manage.py startapp mockme Add django_nose and mocktest.mockme to INSTALLED_APPS (settings.py) Add TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' to settings.py To

Django Unit Testing taking a very long time to create test database

爱⌒轻易说出口 提交于 2019-11-29 22:12:40
For some time now, my unit testing has been taking a longer than expected time. I have tried to debug it a couple of times without much success, as the delays are before my tests even begin to run. This has affected my ability to do anything remotely close to test driven development (maybe my expectations are too high), so I want to see if I can fix this once and for all. When a run a test, there is a 70 to 80sec delay between the start and the actual beginning of the test. For example, if I run a test for a small module (using time python manage.py test myapp ), I get <... bunch of

How to run a single test or single TestCase with django-nose?

我与影子孤独终老i 提交于 2019-11-29 05:25:16
With Django's normal test runner, you can drill down to run tests in a specific app, a specific subclass of TestCase, or a specific test within a specific subclass of TestCase. E.g.: ./manage.py test myapp.MyTestCase.test_something However, django-nose doesn't appear to support anything beyond testing a specific app. How do I replicate the last two behaviors? Nose supports the following syntax (note : between test script name and test class name): ./manage.py test myapp.tests.test_script:MyTestCase.test_method The correct answer is ./manage.py test myapp/tests/test_script:MyTestCase.test