GithubHelp home page GithubHelp logo

jazzband / django-nose Goto Github PK

View Code? Open in Web Editor NEW
882.0 23.0 233.0 427 KB

Django test runner using nose

Home Page: http://pypi.python.org/pypi/django-nose

License: BSD 3-Clause "New" or "Revised" License

Python 90.62% Shell 6.54% Makefile 2.84%

django-nose's Introduction

django-nose

The PyPI package

GitHub Actions

Coverage

Jazzband

django-nose provides all the goodness of nose in your Django tests, like:

  • Testing just your apps by default, not all the standard ones that happen to be in INSTALLED_APPS
  • Running the tests in one or more specific modules (or apps, or classes, or folders, or just running a specific test)
  • Obviating the need to import all your tests into tests/__init__.py. This not only saves busy-work but also eliminates the possibility of accidentally shadowing test classes.
  • Taking advantage of all the useful nose plugins

It also provides:

  • Fixture bundling, an optional feature which speeds up your fixture-based tests by a factor of 4
  • Reuse of previously created test DBs, cutting 10 seconds off startup time
  • Hygienic TransactionTestCases, which can save you a DB flush per test
  • Support for various databases. Tested with MySQL, PostgreSQL, and SQLite. Others should work as well.

django-nose requires nose 1.2.1 or later, and the latest release is recommended. It follows the Django's support policy, supporting:

  • Django 1.8 (LTS) with Python 3.5
  • Django 1.9 with Python 3.5
  • Django 1.10 with Python 3.5
  • Django 1.11 (LTS) with Python 3.5 or 3.6
  • Django 2.0 with Python 3.5, 3.6, or 3.7
  • Django 2.1 with Python 3.5, 3.6, or 3.7
  • Django 2.2 with Python 3.5, 3.6, or 3.7

Note to users

nose has been in maintenance mode since at least 2015. django-nose is in maintenance mode as well, and the sole maintainer is no longer an active user. See Jazzband.co to learn how django-nose is maintained and how you can help. New projects should consider using pytest, or unittest with the Django testing framework.

Installation

You can get django-nose from PyPI with... :

$ pip install django-nose

The development version can be installed with... :

$ pip install -e git://github.com/jazzband/django-nose.git#egg=django-nose

Since django-nose extends Django's built-in test command, you should add it to your INSTALLED_APPS in settings.py:

INSTALLED_APPS = (
    ...
    'django_nose',
    ...
)

Then set TEST_RUNNER in settings.py:

TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'

Development

Code

https://github.com/jazzband/django-nose

Issues

https://github.com/jazzband/django-nose/issues?state=open

Docs

https://django-nose.readthedocs.io

django-nose's People

Contributors

akaihola avatar ashchristopher avatar brad avatar camilonova avatar carljm avatar dcramer avatar dgladkov avatar edrmp avatar erikrose avatar ipmb avatar jazzband-bot avatar jbalogh avatar jezdez avatar jsocol avatar jwhitlock avatar melinath avatar miracle2k avatar moeffju avatar outofculture avatar radeksimko avatar ramiro avatar ravangen avatar robmadole avatar roganov avatar rozza avatar scottsexton avatar singingwolfboy avatar timc3 avatar wdoekes avatar willkg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-nose's Issues

pdb hangs

If you put pdb.set_trace() in a test case, the test runner just hangs waiting for your input, but never displays a pdb prompt. I tried typing "l" to see if it was alive, but it doesn't show any output.

error: could not create '/usr/local/man': File exists

I have ubuntu 11.10 and I'm having this:

$ sudo pip install --upgrade django-nose
Downloading/unpacking django-nose
Running setup.py egg_info for package django-nose

Downloading/unpacking nose (from django-nose)
Running setup.py egg_info for package nose

Installing collected packages: django-nose, nose
Found existing installation: django-nose 0.1.3
Uninstalling django-nose:
Successfully uninstalled django-nose
Running setup.py install for django-nose

Found existing installation: nose 1.1.2
Uninstalling nose:
Successfully uninstalled nose
Running setup.py install for nose
error: could not create '/usr/local/man': File exists
Complete output from command /usr/bin/python -c "import setuptools;file='/home/place/build/nose/setup.py';exec(compile(open(file).read().replace('\r\n', '\n'), file, 'exec'))" install --single-version-externally-managed --record /tmp/pip-KLg6xs-record/install-record.txt:
running install

running build

running build_py

running install_lib

creating /usr/local/lib/python2.7/dist-packages/nose

copying build/lib.linux-i686-2.7/nose/tools.py -> /usr/local/lib/python2.7/dist-packages/nose

copying build/lib.linux-i686-2.7/nose/pyversion.py -> /usr/local/lib/python2.7/dist-packages/nose

copying build/lib.linux-i686-2.7/nose/result.py -> /usr/local/lib/python2.7/dist-packages/nose

copying build/lib.linux-i686-2.7/nose/case.py -> /usr/local/lib/python2.7/dist-packages/nose

copying build/lib.linux-i686-2.7/nose/usage.txt -> /usr/local/lib/python2.7/dist-packages/nose

copying build/lib.linux-i686-2.7/nose/util.py -> /usr/local/lib/python2.7/dist-packages/nose

creating /usr/local/lib/python2.7/dist-packages/nose/sphinx

copying build/lib.linux-i686-2.7/nose/sphinx/pluginopts.py -> /usr/local/lib/python2.7/dist-packages/nose/sphinx

copying build/lib.linux-i686-2.7/nose/sphinx/init.py -> /usr/local/lib/python2.7/dist-packages/nose/sphinx

copying build/lib.linux-i686-2.7/nose/core.py -> /usr/local/lib/python2.7/dist-packages/nose

copying build/lib.linux-i686-2.7/nose/exc.py -> /usr/local/lib/python2.7/dist-packages/nose

copying build/lib.linux-i686-2.7/nose/twistedtools.py -> /usr/local/lib/python2.7/dist-packages/nose

copying build/lib.linux-i686-2.7/nose/config.py -> /usr/local/lib/python2.7/dist-packages/nose

copying build/lib.linux-i686-2.7/nose/proxy.py -> /usr/local/lib/python2.7/dist-packages/nose

copying build/lib.linux-i686-2.7/nose/selector.py -> /usr/local/lib/python2.7/dist-packages/nose

copying build/lib.linux-i686-2.7/nose/commands.py -> /usr/local/lib/python2.7/dist-packages/nose

copying build/lib.linux-i686-2.7/nose/loader.py -> /usr/local/lib/python2.7/dist-packages/nose

copying build/lib.linux-i686-2.7/nose/importer.py -> /usr/local/lib/python2.7/dist-packages/nose

copying build/lib.linux-i686-2.7/nose/inspector.py -> /usr/local/lib/python2.7/dist-packages/nose

creating /usr/local/lib/python2.7/dist-packages/nose/plugins

copying build/lib.linux-i686-2.7/nose/plugins/doctests.py -> /usr/local/lib/python2.7/dist-packages/nose/plugins

copying build/lib.linux-i686-2.7/nose/plugins/testid.py -> /usr/local/lib/python2.7/dist-packages/nose/plugins

copying build/lib.linux-i686-2.7/nose/plugins/capture.py -> /usr/local/lib/python2.7/dist-packages/nose/plugins

copying build/lib.linux-i686-2.7/nose/plugins/logcapture.py -> /usr/local/lib/python2.7/dist-packages/nose/plugins

copying build/lib.linux-i686-2.7/nose/plugins/allmodules.py -> /usr/local/lib/python2.7/dist-packages/nose/plugins

copying build/lib.linux-i686-2.7/nose/plugins/attrib.py -> /usr/local/lib/python2.7/dist-packages/nose/plugins

copying build/lib.linux-i686-2.7/nose/plugins/builtin.py -> /usr/local/lib/python2.7/dist-packages/nose/plugins

copying build/lib.linux-i686-2.7/nose/plugins/skip.py -> /usr/local/lib/python2.7/dist-packages/nose/plugins

copying build/lib.linux-i686-2.7/nose/plugins/multiprocess.py -> /usr/local/lib/python2.7/dist-packages/nose/plugins

copying build/lib.linux-i686-2.7/nose/plugins/isolate.py -> /usr/local/lib/python2.7/dist-packages/nose/plugins

copying build/lib.linux-i686-2.7/nose/plugins/collect.py -> /usr/local/lib/python2.7/dist-packages/nose/plugins

copying build/lib.linux-i686-2.7/nose/plugins/prof.py -> /usr/local/lib/python2.7/dist-packages/nose/plugins

copying build/lib.linux-i686-2.7/nose/plugins/base.py -> /usr/local/lib/python2.7/dist-packages/nose/plugins

copying build/lib.linux-i686-2.7/nose/plugins/deprecated.py -> /usr/local/lib/python2.7/dist-packages/nose/plugins

copying build/lib.linux-i686-2.7/nose/plugins/manager.py -> /usr/local/lib/python2.7/dist-packages/nose/plugins

copying build/lib.linux-i686-2.7/nose/plugins/xunit.py -> /usr/local/lib/python2.7/dist-packages/nose/plugins

copying build/lib.linux-i686-2.7/nose/plugins/cover.py -> /usr/local/lib/python2.7/dist-packages/nose/plugins

copying build/lib.linux-i686-2.7/nose/plugins/failuredetail.py -> /usr/local/lib/python2.7/dist-packages/nose/plugins

copying build/lib.linux-i686-2.7/nose/plugins/init.py -> /usr/local/lib/python2.7/dist-packages/nose/plugins

copying build/lib.linux-i686-2.7/nose/plugins/plugintest.py -> /usr/local/lib/python2.7/dist-packages/nose/plugins

copying build/lib.linux-i686-2.7/nose/plugins/debug.py -> /usr/local/lib/python2.7/dist-packages/nose/plugins

copying build/lib.linux-i686-2.7/nose/plugins/errorclass.py -> /usr/local/lib/python2.7/dist-packages/nose/plugins

copying build/lib.linux-i686-2.7/nose/suite.py -> /usr/local/lib/python2.7/dist-packages/nose

copying build/lib.linux-i686-2.7/nose/init.py -> /usr/local/lib/python2.7/dist-packages/nose

creating /usr/local/lib/python2.7/dist-packages/nose/ext

copying build/lib.linux-i686-2.7/nose/ext/dtcompat.py -> /usr/local/lib/python2.7/dist-packages/nose/ext

copying build/lib.linux-i686-2.7/nose/ext/init.py -> /usr/local/lib/python2.7/dist-packages/nose/ext

copying build/lib.linux-i686-2.7/nose/failure.py -> /usr/local/lib/python2.7/dist-packages/nose

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/tools.py to tools.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/pyversion.py to pyversion.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/result.py to result.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/case.py to case.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/util.py to util.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/sphinx/pluginopts.py to pluginopts.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/sphinx/init.py to init.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/core.py to core.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/exc.py to exc.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/twistedtools.py to twistedtools.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/config.py to config.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/proxy.py to proxy.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/selector.py to selector.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/commands.py to commands.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/loader.py to loader.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/importer.py to importer.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/inspector.py to inspector.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/plugins/doctests.py to doctests.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/plugins/testid.py to testid.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/plugins/capture.py to capture.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/plugins/logcapture.py to logcapture.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/plugins/allmodules.py to allmodules.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/plugins/attrib.py to attrib.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/plugins/builtin.py to builtin.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/plugins/skip.py to skip.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/plugins/multiprocess.py to multiprocess.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/plugins/isolate.py to isolate.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/plugins/collect.py to collect.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/plugins/prof.py to prof.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/plugins/base.py to base.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/plugins/deprecated.py to deprecated.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/plugins/manager.py to manager.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/plugins/xunit.py to xunit.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/plugins/cover.py to cover.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/plugins/failuredetail.py to failuredetail.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/plugins/init.py to init.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/plugins/plugintest.py to plugintest.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/plugins/debug.py to debug.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/plugins/errorclass.py to errorclass.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/suite.py to suite.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/init.py to init.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/ext/dtcompat.py to dtcompat.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/ext/init.py to init.pyc

byte-compiling /usr/local/lib/python2.7/dist-packages/nose/failure.py to failure.pyc

running install_data

creating /usr/local/man

error: could not create '/usr/local/man': File exists


Rolling back uninstall of nose
Command /usr/bin/python -c "import setuptools;file='/home/place/build/nose/setup.py';exec(compile(open(file).read().replace('\r\n', '\n'), file, 'exec'))" install --single-version-externally-managed --record /tmp/pip-KLg6xs-record/install-record.txt failed with error code 1
Storing complete log in /home/cherny/.pip/pip.log

Verbosity

The default DjangoTestRunner is inherited from unittest.TextTestRunner, which creates output using unittest._TextTestResult.

This output is actually very convenient, as it shows the test case name with the result, but django-nose does not do that.

Is there a result plugin coming or is that even the proper way to approach this shortcoming?

Inconsistent behavior when running tests

I have two django projects and django-nose seems to behave differently with each one.

The first project is smaller. I run

$ python manage.py test app1 app2 app3

And only the tests in those apps are run. It works perfectly. It's amazingly fast and flawless.

However, the other project, which is a lot bigger has problems. It seems to ignore my requests to only test certain app. It instead tests applications that are in my INSTALLED_APPS and beyond. For example, it will run Sentry's tests without being asked to. I read in 34 that it looks at everything on the Python path. Why is that? Why does it work in the first app?

Thanks!

parses long options with no equals sign incorrectly

Python's optparse accepts long options also without the equals sign (e.g. --verbose 2). Django-nose fails to strip out the values of such Django options when creating the nose command line:

$ ./manage.py test --verbosity 0
======================================================================
ERROR: Failure: OSError (No such file /home/akaihola/testproject/0)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.6/nose/failure.py", line 39, in runTest
    raise self.exc_class(self.exc_val)
OSError: No such file /home/akaihola/testproject/0

----------------------------------------------------------------------
Ran 20 tests in 2.844s

FAILED (errors=1)

To solve this "correctly", some serious hacking with optparse is probably needed. Or, known Django options with arguments could be handled specially.

Or maybe it would be possible to "merge" Django's and nose's option parsers?

Correctly support Django options

I'm not entirely sure how the _get_options stuff functions, but our custom code does something slightly different, which actually makes --noinput/etc work for us::

def _get_options():
    """Return all nose options that don't conflict with django options."""
    cfg_files = nose.core.all_config_files()
    manager = nose.core.DefaultPluginManager()
    config = nose.core.Config(env=os.environ, files=cfg_files, plugins=manager)
    config.plugins.addPlugins(list(_get_plugins_from_settings()))
    cmd_opts = tuple(Command.option_list)
    options = tuple(config.getParser()._get_all_options()) + cmd_opts
    django_opts = [opt.dest for opt in BaseCommand.option_list] + ['version']
    return tuple(o for o in options if o.dest not in django_opts and
                                       o.action != 'help')

Models located in tests.py are not created

Models that exists only for testing purpose are not created when tests running by django_nose

Problem exists because setup_databases called before any test module have been imported.

This could be fixed by moving setup_databases call into prepareTest in Plugin

Supporting standalone test runner

This is more of a draft idea, and I'm not entirely sure how we should approach it, but it'd be nice if we could somehow support a standalone test runner a bit easier.

Right now I end up with something containing, at minimum, the following::

#!/usr/bin/env python
import sys
import os, os.path
from optparse import OptionParser

from django.conf import settings

parent = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, parent)

if 'DJANGO_SETTINGS_MODULE' not in os.environ:
    os.environ['DJANGO_SETTINGS_MODULE'] = 'disqus.conf.settings.test'

from django_nose import NoseTestSuiteRunner

def runtests(*test_args, **kwargs):
    if 'south' in settings.INSTALLED_APPS:
        from south.management.commands import patch_for_test_db_setup
        patch_for_test_db_setup()

    test_runner = NoseTestSuiteRunner(**kwargs)

    failures = test_runner.run_tests(test_args)
    sys.exit(failures)

if __name__ == '__main__':
    parser = OptionParser()
    parser.add_option('--verbosity', dest='verbosity', action='store', default=1, type=int)
    parser.add_options(NoseTestSuiteRunner.options)
    (options, args) = parser.parse_args()

    if not args:
        args = ['tests', 'disqus']

    runtests(*args, **options.__dict__)

Possible to make optional for the project?

I have a project for which I would like to use django-nose for testing, but I would prefer not to require django-nose to be present for the app itself to run. (For example, I don't want production installations of our product to require django-nose - they won't be running unit tests and I'd like to minimize what they have to install). I can't just test if django-nose is importable in settings.py, because when it tries to import it there is an Import Error:

ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.

Is this currently possible?

Keep unaltered the order of settings.INSTALLED_APPS

Hi Jeff,

Is there a chance we can keep unaltered the order of the apps in INSTALLED_APPS? At https://github.com/jbalogh/django-nose/blob/master/django_nose/plugin.py#L63 the order gets lost, so things like admin.autodiscover work differently depending on the computer you are running the tests. This causes problems if you are using admin.site.unregister.

(Oops, I just noticed I was logged in another account. I am https://github.com/zuzelvp)

Thanks,
Zuzel

NoseTestSuiteRunner.run_tests does not respect test_labels arg

The run_tests() method of NoseTestSuiteRunner ignores its test_labels arg. The only reason "manage.py test foo.bar:SomeSuite" still works is that it gets picked up in the looping over sys.argv[:2]. Unfortunately this [:2] makes unwarranted assumptions, and breaks in cases where the NoseTestSuiteRunner is being used via the Python API, not run via "manage.py test". It would be better if run_tests used the test_labels argument that it is passed.

I have a branch with a working fix for this, including a test that fails without the fix. All existing tests still pass. The branch is here: http://github.com/carljm/django-nose/commits/run_tests_api

Port TransactionTestCase from test_utils

Imagine we have a couple of TransactionTestCases, and they take 7 seconds each to flush the DB. Let's grab the non-flushing, table-truncating version out of test-utils and see if we can genericize it.

Hack that defers post_syncdb doesn't work

There is a hack (labelled hack) that defers post_syncdb, removing those lines fixes the issue described at http://stackoverflow.com/questions/6929437/django-nose-doesnt-load-basic-fixtures-e-g-django-site-example-com-entry-or-ad

The following patch disables/removes the hack which works for me:

diff --git a/django_nose/plugin.py b/django_nose/plugin.py
index d457cc2..f8f6290 100644
--- a/django_nose/plugin.py
+++ b/django_nose/plugin.py
@@ -76,12 +76,7 @@ class DjangoSetUpPlugin(object):

         self.runner.setup_test_environment()

-        # HACK: We need to kill post_syncdb receivers to stop them from sending
-        # when the databases arent fully ready.
-        post_syncdb_receivers = signals.post_syncdb.receivers
-        signals.post_syncdb.receivers = []
         self.old_names = self.runner.setup_databases()
-        signals.post_syncdb.receivers = post_syncdb_receivers

         for app in get_apps():
             app_models = list(get_models(app, include_auto_created=True))

django.db.utils.DatabaseError: column "id" does not exist

I have a model which inherit from other model. When I'm trying to use to use NoseTestSuiteRunner I get

django.db.utils.DatabaseError: column "id" does not exist

It caused in runner.py on line 300

for reset_statement in reset_statements:
cursor.execute(reset_statement)

printed reset_statement
...
SELECT setval(pg_get_serial_sequence('"visualcontent_brandslideshowimage"','id'), coalesce(max("id"), 1), max("id") IS NOT null) FROM "visualcontent_brandslideshowimage";
here goes python traceback

Obviously I don't have id in visualcontent_brandslideshowimage because it inherited from another model. Please, advise.

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 15: ordinal not in range(128)

If I write a test like this:

self.assertContains(response, u'名')

I get a stacktrace like this:

Traceback (most recent call last):
  File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/nose/case.py", line 133, in run
    self.runTest(result)
  File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/nose/case.py", line 151, in runTest
    test(result)
  File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/test/testcases.py", line 264, in __call__
    super(TransactionTestCase, self).__call__(result)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/unittest.py", line 300, in __call__
    return self.run(*args, **kwds)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/unittest.py", line 282, in run
    result.addFailure(self, self._exc_info())
  File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/nose/proxy.py", line 136, in addFailure
    formatted = plugins.formatFailure(self.test, err)
  File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/nose/plugins/manager.py", line 94, in __call__
    return self.call(*arg, **kw)
  File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/nose/plugins/manager.py", line 136, in chain
    result = meth(*arg, **kw)
  File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/nose/plugins/capture.py", line 86, in formatFailure
    return self.formatError(test, err)
  File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/nose/plugins/capture.py", line 81, in formatError
    return (ec, self.addCaptureToErr(ev, output), tb)
  File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/nose/plugins/capture.py", line 90, in addCaptureToErr
    output, ln('>> end captured stdout <<')])
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 15: ordinal not in range(128)

It is not able to print the unicode character. Running it in the django test runner we get the output correctly:

AssertionError: Couldn't find '名' in response

Here's my setup:

 $ pip freeze | grep nose
django-nose==0.1.2
nose==1.0.0

Duplicate test reporting

I'm not sure if this is an upstream question, but I'll start here. It is common to split large test suites inside an application like this:

myapp/
  __init__.py
  models.py
  tests/
    __init__.py
    test_views.py
    test_models.py
  views.py

tests/__init__.py would look like this:

from test_views import *
from test_models import *

Nose finds the tests in tests_*.py and imports them again in __init__.py. This results in the total number of tests reported being double what they should be.

Any ways around this problem (other than never using sub-modules) that will correctly report the tests with both django-nose and the default Django test runner?

Mac OSX artifacts in tar.gz

There are several Mac OSX related artifacts in the released tarball at pypi.python.org:
django-nose-0.1/._LICENSE
django-nose-0.1/._MANIFEST.in
django-nose-0.1/django_nose.egg-info/._dependency_links.txt
django-nose-0.1/django_nose.egg-info/._not-zip-safe
django-nose-0.1/django_nose.egg-info/._PKG-INFO
django-nose-0.1/django_nose.egg-info/._requires.txt
django-nose-0.1/django_nose.egg-info/._SOURCES.txt
django-nose-0.1/django_nose.egg-info/._top_level.txt
django-nose-0.1/django_nose/._plugin.py
django-nose-0.1/django_nose/management/._init.py
django-nose-0.1/django_nose/management/commands/._init.py

I think the should not be shipped in a release.

Coverage, stdout and imported models

This is mix of tickets #2 and #19, which have been closed but #19 caused regression in #2. I can't see how to reopen so have added a new ticket here!

The issues are:
#2 --with-coverage tracked coverage after import of models
#19 the fix for #2 had a side affect and snaffled stdout, but in fixing we regressed #2.

This can be fixed by removing the score and then manually handling stdout. http://gist.github.com/500598 does work, it allows stdout and allows coverage to be run before imports.

Or you can clone http://github.com/rozza/django-nose to test.

Running contrib tests

I'm noob, but it seems odd then when I run 'manage.py test' on a new django install it runs 30 odd tests from within the contrib apps, but when I change the test runner to djangonose it runs 0.

-Jesse

issue with using get_app and get_apps

Hi Jeff,

I have another issue from the latest changes to django_nose/plugin.py. I will keep looking for a fix, but as a first step I am creating the ticket.

The bug is that the admin.py modules are imported twice raising the AlreadyRegistered exception.

The problem occurs because https://github.com/jbalogh/django-nose/blob/master/django_nose/plugin.py#L100 calls load_app with 'lernanta.apps.links' and https://github.com/jbalogh/django-nose/blob/master/django_nose/plugin.py#L104 causes a call to load_app with 'links'.

I will reply as soon as i find a fix (either on django_nose or on our source code). It should work if I manage to change something so that both times load_app is called with the same qualified name.

Thanks,
Zuzel

django-nose returns 0 for failure.

When my tests run, django-nose returns 1 for success, causing Hudson to mark all my builds as failed. There's no option to tweak this, either...

Method definitions as missing

Might be a problem on my side, but when I run some tests like this:
python manage.py test project.utils --with-coverage --cover-package=project.utils.cache_util

I get

Name Stmts Miss Cover Missing

project.utils.cache_util 61 16 74% 1-11, 32, 40, 45, 52, 56, 64, 75, 78, 81, 84, 93

All those missing are either imports or class definitions or class methods.

Any ideas?

[django-1.2] verbosity option could be more flexible

In the django-1.2 branch, the --verbosity Django option is passed to nose as well. This creates these glitches:

  • To list tests as rows instead of dots, nose needs --verbosity=2. Unfortunately, it makes Django fixture loading verbose, too.
  • settings.NOSE_ARGS can include --verbosity, but it's appended to the nose arguments in addition to the --verbosity from the command line. The NOSE_ARGS setting overrides the command line setting, which may or may not be desirable.

One solution is to add a --nose-verbosity option which is passed to nose as --verbosity and defaults to the value of the --verbosity option. See 0ae4bb0 for an implementation.

different behavior with "django-admin.py test" and "manage.py test"

when in the project directory containing manage.py I can run:

python manage.py test justmyapp

and only the tests for justmyapp will be run. However when I run

django-admin.py test justmyapp --settings=myproject.settings

I get an import error regarding justmyapp. I realize that nose's test discovery is vastly different from the default django test runner, but I would hope that nose can still be leveraged via django-admin.py. Also running:

django-admin.py test myproject.justmyapp --settings=myproject.settings

no longer gives me an import error, but 0 tests are run.

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

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 my_app

I installed django-nose. When I try to run the tests with django-nose, 0 tests are run:
$ python manage.py test my_app

If I point directly at the test module, the tests are run:
$ python manage.py test my_project.apps.my_app.tests.storage_tests

Why does django-nose's test runner not find my tests? What must I do?

Unable to determine if django_nose is installed

I want to include django_nose in the project settings only if it is installed:

try:
    import django_nose
    INSTALLED_APPS += ['django_nose']
    TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
except ImportError:
    pass

I expected that to work, but I get an ImportError: Settings cannot be imported ... exception. The problem is that django_nose/__init__.py imports everything from django_nose/runner.py, which in turn imports Django and breaks.

As last resort I could check the ImportError message itself, but I hope there is a cleaner solution to this.

Merge conflicts

Installing django-nose.
remote: Counting objects: 200, done.
remote: Compressing objects: 100% (197/197), done.
remote: Total 200 (delta 101), reused 0 (delta 0)
fatal: git checkout: --track and --no-track require -b
From git://github.com/jbalogh/django-nose

  • branch django-1.2 -> FETCH_HEAD
    Auto-merged README.rst
    CONFLICT (content): Merge conflict in README.rst
    Auto-merged django_nose/management/commands/test.py
    CONFLICT (content): Merge conflict in django_nose/management/commands/test.py
    Auto-merged django_nose/runner.py
    CONFLICT (content): Merge conflict in django_nose/runner.py
    Auto-merged runtests.sh
    CONFLICT (add/add): Merge conflict in runtests.sh
    Auto-merged testapp/settings.py
    CONFLICT (add/add): Merge conflict in testapp/settings.py
    Automatic merge failed; fix conflicts and then commit the result.
    While:
    Installing django-nose.
    Error: Failed to update repository

Guys we are using this runner so please be careful while commiting :D

missing 'score' attribute breaks nose's "-p" at verbosity level 2

Using nose 1.1.2 and django-nose 0.1.3, printing the list of plugins at verbosity level 2 throws the following exception:

$ ./manage.py test -p --verbosity 2
Plugin django setup
Traceback (most recent call last):
  File "./manage-dev", line 11, in <module>
    execute_manager(settings)
  File "/home/abeld/WORK/myproject/env/src/django/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/home/abeld/WORK/myproject/env/src/django/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/abeld/WORK/myproject/env/src/django/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/abeld/WORK/myproject/env/src/django/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/home/abeld/WORK/myproject/env/local/lib/python2.7/site-packages/south/management/commands/test.py", line 8, in handle
    super(Command, self).handle(*args, **kwargs)
  File "/home/abeld/WORK/myproject/env/src/django/django/core/management/commands/test.py", line 37, in handle
    failures = test_runner.run_tests(test_labels)
  File "/home/abeld/WORK/myproject/env/local/lib/python2.7/site-packages/django_nose/runner.py", line 85, in run_tests
    result = self.run_suite(nose_argv)
  File "/home/abeld/WORK/myproject/env/local/lib/python2.7/site-packages/django_nose/runner.py", line 49, in run_suite
    addplugins=plugins_to_add)
  File "/home/abeld/WORK/myproject/env/local/lib/python2.7/site-packages/nose/core.py", line 118, in __init__
    **extra_args)
  File "/usr/lib/python2.7/unittest/main.py", line 94, in __init__
    self.parseArgs(argv)
  File "/home/abeld/WORK/myproject/env/local/lib/python2.7/site-packages/nose/core.py", line 147, in parseArgs
    self.showPlugins()
  File "/home/abeld/WORK/myproject/env/local/lib/python2.7/site-packages/nose/core.py", line 219, in showPlugins
    print "  score: %s" % p.score
AttributeError: 'DjangoSetUpPlugin' object has no attribute 'score'

Based on http://readthedocs.org/docs/nose/en/latest/plugins/interface.html saying "must have the attributes enabled, name and score", I assume it is django-nose's fault for not having that attribute.

license missing

The setup.py file specifies BSD license, but there is no actual license text included with the project.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.