Question

I just re-wrote a large chunk of Django code that had to do with a 40-something state FSM. There are a lot of STATE_DEFINITIONS = "4.7.1" for each of the three models involved, and lots of checks if the current state == SOME_STATE or in [ONE_STATE, OR_ANOTHER].

There is only one place in which I use a dictionary. say one of the models looks like:

class OneModel(models.Model):
    STATUS_ONE = "1.0"
    STATUS_TWO = "2.0"

    STATUS_MAPPING = {
              STATUS_ONE:OtherModel.STATUS_X,
              STATUS_TWO:OtherModels.STATUS_Y,
    }

All the keys are unique strings, and if I remove it from the code the same thing happens.

When I python manage.py test my_app I get what is probably the least helpful error message ever: TypeError: unhashable type: 'list' That's it, no line where it happens, no context. Does anyone have any suggestions on how to debug this that does not involve going line by line of the 800+ in the file?

Was it helpful?

Solution

Try passing the --traceback option.

OTHER TIPS

Check manage.py for exception swallowing behavior; may be something like:

try:
    ....
except Exception, exc:
    print exc.message

If you find it, make it raise instead so you can see whole traceback.

If you have ipython installed, you can try:ipython -i manage.py test my_app. then input %debug command to debug it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top