Thursday, March 12, 2015

Last adaptions in test suites after yesterday’s changes.

UnicodeEncodeError

I had a UnicodeEncodeError when running the show command:

$ python manage.py show pcsw.StrangeClients

Traceback (most recent call last):
  ...
  File ".../lino/core/renderer.py", line 308, in show_request
    print(ar.to_rst(*args, **kw))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 1712: ordinal not in range(128)

But Lino was innocent. It was because the terminal or the system was poorly configured. See https://wiki.python.org/moin/PrintFails

My ~/.bashrc contained:

export LANG=en_GB.UTF-8

and I solved it by changing this to:

export LANG=C.UTF-8

after invoking locale -a in order to see which locales are available:

$ locale -a
C
C.UTF-8
POSIX
fr_BE.utf8

Another workaround was to set PYTHONIOENCODING to “utf-8”.

Repairable data

Tonight I had the inspiration for solving a series of subtle but disturbing problems:

  • pcsw.Clients with an SSIN which actually is valid, but wrongly formatted

  • some Partners have a single address, but which is not marked as primary

  • some Calendar events should have their client as guest, but they don’t have

The solution is a new module lino.mixins.repairable and a django-admin command repairdata.

The first item of above list is already implemented, tested by lino_welfare.projects.std.tests.test_beid. I also worked on the documentation of lino.utils.ssin. The other two items are for tomorrow…