BUG: Fix str/unicode warnings from SQLAlchemy on python 2.

When running with `reset_db=True` on python 2, several SQLAlchemy operations
were performed with bytes where unicode was expected, resulting in
warnings like the following.

```
/home/ssanderson/.virtualenvs/jupyterhub/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py:573:
SAWarning: Unicode type received non-unicodebind param value.
  param.append(processors[key](compiled_params[key]))
```

Fixes a few stray non-unicode literals and adds a unicode safe wrapper
for `getpass.getuser`.
This commit is contained in:
Scott Sanderson
2014-10-25 17:46:25 -04:00
parent fa7250ecc3
commit a34d514d66
3 changed files with 20 additions and 10 deletions

View File

@@ -3,13 +3,13 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import getpass
import logging
from pytest import fixture
from tornado import ioloop
from .. import orm
from ..utils import getuser_unicode
from .mocking import MockHubApp
@@ -24,7 +24,7 @@ def db():
if _db is None:
_db = orm.new_session('sqlite:///:memory:', echo=True)
user = orm.User(
name=getpass.getuser(),
name=getuser_unicode(),
server=orm.Server(),
)
hub = orm.Hub(