Ticket #586 (closed defect: invalid)

Opened 4 years ago

Last modified 3 years ago

South introduced errors in rpc4django unit tests.

Reported by: jude@… Owned by: andrew
Priority: major Milestone: The Future
Component: commands Version: unknown
Keywords: Cc:

Description (last modified by andrew) (diff)

When I have my INSTALLED_APPS set to just include the south and rpc4django (http://www.davidfischer.name/rpc4django/) apps, I get errors in the rpc4djamgo unit tests when running 'python manage.py test'

Most of them look something like the stack trace below. It looks like south is setting the rpc4django.views._is_xmlrpc_request function is being replaced with None somehow.

If I include SOUTH_TESTS_MIGRATE=False in my settings.py file, all the south and rpc4django tests pass.

If I include SSKIP_SOUTH_TESTS=True in my settings.py, I still see the rpc4django unit test errors.

I don't know if it matters or not, but rpc4django egg has an empty model. (http://bazaar.launchpad.net/~djfische/rpc4django/main/annotate/head%3A/rpc4django/models.py)

I've seen this with Django 1.1.1 and 1.2.3, South 0.7.2 and rpc4django 0.1.7.

======================================================================
ERROR: test_httpaccesscontrol (rpc4django.tests.test_rpcviews.TestRPCViews)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/me/projects/south_and_rpc4django/env/lib/python2.6/site-packages/rpc4django-0.1.7-py2.6.egg/rpc4django/tests/test_rpcviews.py", line 111, in test_httpaccesscontrol
    response = self.client.options(RPCPATH, '', 'text/plain')
  File "/home/me/projects/south_and_rpc4django/env/lib/python2.6/site-packages/Django-1.2.3-py2.6.egg/django/test/client.py", line 367, in options
    response = self.request(**r)
  File "/home/me/projects/south_and_rpc4django/env/lib/python2.6/site-packages/Django-1.2.3-py2.6.egg/django/core/handlers/base.py", line 100, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/home/me/projects/south_and_rpc4django/env/lib/python2.6/site-packages/rpc4django-0.1.7-py2.6.egg/rpc4django/views.py", line 173, in serve_rpc_request
    response = HttpResponse('', 'text/plain')
TypeError: 'NoneType' object is not callable

Change History

comment:1 Changed 4 years ago by andrew

  • Status changed from new to infoneeded
  • Description modified (diff)
  • Milestone set to 0.7.3

That's very odd - it looks like it's managing to make HttpResponse? = None, which is definitely not a direct result of South. What sort of migration set/view code are we dealing with here - is it possible to reduce it to a smaller test + view that replicates the bug?

comment:2 Changed 4 years ago by anonymous

  • Status changed from infoneeded to assigned

I set my INSTALLED_APPS list to just 'rpc4django' and 'south' :

INSTALLED_APPS = ( 'rpc4django', 'south')
SOUTH_TEST_MIGRATE = False

The run 'python manage.py test', and I get 28 passing tests.

If I change SOUTH_TEST_MIGRATE=True, then I get the errors below. There are no migrations involved. I'm running through the eggs' test suites.

../env/bin/python manage.py test
Creating test database...
Syncing...
Creating table south_migrationhistory
Migrating...

Synced:
 > rpc4django
 > south

Migrated:
 - 
...................../home/my-project/env/lib/python2.6/site-packages/pyPdf-1.12-py2.6.egg/pyPdf/pdf.py:52: DeprecationWarning: the sets module is deprecated
  from sets import ImmutableSet
EEEEEE.
======================================================================
ERROR: test_badrequests (rpc4django.tests.test_rpcviews.TestRPCViews)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/my-project/env/lib/python2.6/site-packages/rpc4django-0.1.7-py2.6.egg/rpc4django/tests/test_rpcviews.py", line 86, in test_badrequests
    response = self.client.post(RPCPATH, data, 'application/json')
  File "/home/my-project/env/lib/python2.6/site-packages/Django-1.1.2-py2.6.egg/django/test/client.py", line 317, in post
    response = self.request(**r)
  File "/home/my-project/env/lib/python2.6/site-packages/Django-1.1.2-py2.6.egg/django/test/client.py", line 225, in request
    response = self.handler(environ)
  File "/home/my-project/env/lib/python2.6/site-packages/Django-1.1.2-py2.6.egg/django/test/client.py", line 69, in __call__
    response = self.get_response(request)
  File "/home/my-project/env/lib/python2.6/site-packages/Django-1.1.2-py2.6.egg/django/core/handlers/base.py", line 76, in get_response
    response = middleware_method(request)
  File "/home/my-project/env/lib/python2.6/site-packages/Django-1.1.2-py2.6.egg/django/middleware/common.py", line 57, in process_request
    if (not _is_valid_path(request.path_info, urlconf) and
  File "/home/my-project/env/lib/python2.6/site-packages/Django-1.1.2-py2.6.egg/django/middleware/common.py", line 143, in _is_valid_path
    urlresolvers.resolve(path, urlconf)
  File "/home/my-project/env/lib/python2.6/site-packages/Django-1.1.2-py2.6.egg/django/core/urlresolvers.py", line 309, in resolve
    return get_resolver(urlconf).resolve(path)
  File "/home/my-project/env/lib/python2.6/site-packages/Django-1.1.2-py2.6.egg/django/core/urlresolvers.py", line 222, in resolve
    sub_match = pattern.resolve(new_path)
  File "/home/my-project/env/lib/python2.6/site-packages/Django-1.1.2-py2.6.egg/django/core/urlresolvers.py", line 129, in resolve
    return self.callback, args, kwargs
  File "/home/my-project/env/lib/python2.6/site-packages/Django-1.1.2-py2.6.egg/django/core/urlresolvers.py", line 135, in _get_callback
    self._callback = get_callable(self._callback_str)
  File "/home/my-project/env/lib/python2.6/site-packages/Django-1.1.2-py2.6.egg/django/utils/functional.py", line 130, in wrapper
    result = func(*args)
  File "/home/my-project/env/lib/python2.6/site-packages/Django-1.1.2-py2.6.egg/django/core/urlresolvers.py", line 62, in get_callable
    lookup_view = getattr(import_module(mod_name), func_name)
  File "/home/my-project/env/lib/python2.6/site-packages/Django-1.1.2-py2.6.egg/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/home/my-project/env/lib/python2.6/site-packages/rpc4django-0.1.7-py2.6.egg/rpc4django/views.py", line 230, in <module>
    dispatcher = RPCDispatcher(URL, APPS, RESTRICT_INTROSPECTION)
  File "/home/my-project/env/lib/python2.6/site-packages/rpc4django-0.1.7-py2.6.egg/rpc4django/rpcdispatcher.py", line 168, in __init__
    self.register_rpcmethods(apps)
  File "/home/my-project/env/lib/python2.6/site-packages/rpc4django-0.1.7-py2.6.egg/rpc4django/rpcdispatcher.py", line 245, in register_rpcmethods
    self.register_rpcmethods(["%s.%s" % (appname, obj)])
  File "/home/my-project/env/lib/python2.6/site-packages/rpc4django-0.1.7-py2.6.egg/rpc4django/rpcdispatcher.py", line 245, in register_rpcmethods
    self.register_rpcmethods(["%s.%s" % (appname, obj)])
  File "/home/my-project/env/lib/python2.6/site-packages/rpc4django-0.1.7-py2.6.egg/rpc4django/rpcdispatcher.py", line 245, in register_rpcmethods
    self.register_rpcmethods(["%s.%s" % (appname, obj)])
  File "/home/my-project/env/lib/python2.6/site-packages/rpc4django-0.1.7-py2.6.egg/rpc4django/rpcdispatcher.py", line 233, in register_rpcmethods
    app = __import__(appname, globals(), locals(), ['*'])
ValueError: Empty module name

======================================================================
ERROR: test_httpaccesscontrol (rpc4django.tests.test_rpcviews.TestRPCViews)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/my-project/env/lib/python2.6/site-packages/rpc4django-0.1.7-py2.6.egg/rpc4django/tests/test_rpcviews.py", line 111, in test_httpaccesscontrol
    response = self.client.options(RPCPATH, '', 'text/plain')
  File "/home/my-project/env/lib/python2.6/site-packages/Django-1.1.2-py2.6.egg/django/test/client.py", line 354, in options
    response = self.request(**r)
  File "/home/my-project/env/lib/python2.6/site-packages/Django-1.1.2-py2.6.egg/django/core/handlers/base.py", line 99, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/home/my-project/env/lib/python2.6/site-packages/rpc4django-0.1.7-py2.6.egg/rpc4django/views.py", line 168, in serve_rpc_request
    response = HttpResponse('', 'text/plain')
TypeError: 'NoneType' object is not callable

======================================================================
ERROR: test_jsonrequests (rpc4django.tests.test_rpcviews.TestRPCViews)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/my-project/env/lib/python2.6/site-packages/rpc4django-0.1.7-py2.6.egg/rpc4django/tests/test_rpcviews.py", line 32, in test_jsonrequests
    response = self.client.post(RPCPATH, data, 'application/json')
  File "/home/my-project/env/lib/python2.6/site-packages/Django-1.1.2-py2.6.egg/django/test/client.py", line 317, in post
    response = self.request(**r)
  File "/home/my-project/env/lib/python2.6/site-packages/Django-1.1.2-py2.6.egg/django/core/handlers/base.py", line 99, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/home/my-project/env/lib/python2.6/site-packages/rpc4django-0.1.7-py2.6.egg/rpc4django/views.py", line 139, in serve_rpc_request
    if _is_xmlrpc_request(request):
TypeError: 'NoneType' object is not callable

======================================================================
ERROR: test_methodsummary (rpc4django.tests.test_rpcviews.TestRPCViews)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/my-project/env/lib/python2.6/site-packages/rpc4django-0.1.7-py2.6.egg/rpc4django/tests/test_rpcviews.py", line 20, in test_methodsummary
    response = self.client.get(RPCPATH)
  File "/home/my-project/env/lib/python2.6/site-packages/Django-1.1.2-py2.6.egg/django/test/client.py", line 285, in get
    response = self.request(**r)
  File "/home/my-project/env/lib/python2.6/site-packages/Django-1.1.2-py2.6.egg/django/core/handlers/base.py", line 99, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/home/my-project/env/lib/python2.6/site-packages/rpc4django-0.1.7-py2.6.egg/rpc4django/views.py", line 192, in serve_rpc_request
    methods = dispatcher.list_methods()
NameError: global name 'dispatcher' is not defined

======================================================================
ERROR: test_typedetection (rpc4django.tests.test_rpcviews.TestRPCViews)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/my-project/env/lib/python2.6/site-packages/rpc4django-0.1.7-py2.6.egg/rpc4django/tests/test_rpcviews.py", line 49, in test_typedetection
    response = self.client.post(RPCPATH, data, 'text/plain')
  File "/home/my-project/env/lib/python2.6/site-packages/Django-1.1.2-py2.6.egg/django/test/client.py", line 317, in post
    response = self.request(**r)
  File "/home/my-project/env/lib/python2.6/site-packages/Django-1.1.2-py2.6.egg/django/core/handlers/base.py", line 99, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/home/my-project/env/lib/python2.6/site-packages/rpc4django-0.1.7-py2.6.egg/rpc4django/views.py", line 139, in serve_rpc_request
    if _is_xmlrpc_request(request):
TypeError: 'NoneType' object is not callable

======================================================================
ERROR: test_xmlrequests (rpc4django.tests.test_rpcviews.TestRPCViews)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/my-project/env/lib/python2.6/site-packages/rpc4django-0.1.7-py2.6.egg/rpc4django/tests/test_rpcviews.py", line 26, in test_xmlrequests
    response = self.client.post(RPCPATH, data, 'text/xml')
  File "/home/my-project/env/lib/python2.6/site-packages/Django-1.1.2-py2.6.egg/django/test/client.py", line 317, in post
    response = self.request(**r)
  File "/home/my-project/env/lib/python2.6/site-packages/Django-1.1.2-py2.6.egg/django/core/handlers/base.py", line 99, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/home/my-project/env/lib/python2.6/site-packages/rpc4django-0.1.7-py2.6.egg/rpc4django/views.py", line 139, in serve_rpc_request
    if _is_xmlrpc_request(request):
TypeError: 'NoneType' object is not callable

----------------------------------------------------------------------
Ran 28 tests in 0.382s

FAILED (errors=6)
Destroying test database...

comment:3 Changed 4 years ago by andrew

  • Milestone changed from 0.7.3 to The Future

I really don't know what's going on here. I'm going to have to bump this to The Future unless I can get a whole day to sit down and figure this out.

comment:4 Changed 4 years ago by David Fischer <djfische@…>

I'm the developer of RPC4Django and I can't reproduce this issue.

I setup a test environment with the exact versions of South, RPC4Django and Django specified in the ticket but I consistently got all the unit tests passing. I'm not sure why they weren't passing for Jude.

However, I'm happy to take a more in-depth look at this issue if the author can give me some more information or send me the exact project that is causing the issue.

comment:5 Changed 4 years ago by andrew

  • Status changed from assigned to infoneeded

Alright, bumping this to "infoneeded". We'll close it if there's no timely response.

comment:6 Changed 3 years ago by dom@…

  • Status changed from infoneeded to assigned

Hmm, is there any update for this issue? I am experiencing similar errors with south + rpc4django. All unit tests for my app pass when I set SOUTH_TESTS_MIGRATE=False.

Thanks,
Dom

comment:7 Changed 3 years ago by andrew

  • Status changed from assigned to infoneeded

I'm afraid not, since there was no response from the original author and the developer of rpc4django couldn't reproduce it. If you can reduce it to a single, simple app that fails and attach it, we might have a better chance of working out what's wrong.

(Note that any attached example has to be simple - if you just zip up an entire project and dump it there I have no hope of tracing the fault. It needs to be one model, preferably, and one or two migrations and one or two tests).

comment:8 Changed 3 years ago by David Fischer <djfische@…>

So I was unable to reproduce it on my Mac (Python 2.7.0 from homebrew) but I am able to reproduce it on Ubuntu 11.04 (Python 2.7.1). Both are using virtualenvs with --no-site-packages and the same packages (Django 1.3.0, South 0.7.3, RPC4Django 0.1.8). I created a simple Django project with only South and RPC4Django installed on top of the default INSTALLED_APPS. Curious indeed.

RPC4Django recursively imports all the apps in INSTALLED_APPS looking for methods with a particular decorator. It just caught all ImportErrors and moved on. However, import can throw a ValueError in certain cases and that was not being caught and caused a cascading error.

I'm not sure why I wasn't seeing this error on MacOS, but it is resolved. I'll push a fix to RPC4Django momentarily.

comment:9 Changed 3 years ago by dom@…

  • Status changed from infoneeded to assigned

@David Fischer: this is great news! Thanks for fixing the issue. And yes, I am also using Kubuntu 11.04 (Python 2.7.1) and virtualenv(wrapper) with Django 1.3.0, South 0.7.3, RPC4Django 0.1.8). Will there be a RPC4Django release in the near future?

We are using RPC4Django in the Caruso project http://www.caruso.mobi for communication between smartphone client and server and are very happy with it. David, thanks for RPC4Django!

comment:10 Changed 3 years ago by David Fischer <djfische@…>

@Dom
I'll get a release out this weekend.

I'm really happy to hear that you're using RPC4Django (and South!). I had taken a look at your website yesterday and it looks like a great project. It's always nice to see your work used for good.

In the meantime, give the latest code a try and see if it fixes your specific problem. Also, since this bug is from RPC4Django, we should probably take the discussion elsewhere. Sorry for hijacking your issue tracker Andrew.

comment:11 Changed 3 years ago by andrew

  • Status changed from assigned to closed
  • Resolution set to invalid

No problem, thanks for fixing the bug; I'll close the ticket.

Note: See TracTickets for help on using tickets.