Issue: test failures under py3 in latest release
Author: idella
State: closed
Created: 2014-06-02 05:03:56

On the presumption peewee is intended to support py3. we have the following;
Running with system python 3.3;

``` python
======================================================================
ERROR: test_slicing_dicing (tests.QueryResultWrapperTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/tests.py", line 1461, in test_slicing_dicing
    res = uq[5:]
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/peewee.py", line 2000, in __getitem__
    if index >= 0:
TypeError: unorderable types: NoneType() >= int()

======================================================================
ERROR: test_slicing_dicing (tests.QueryResultWrapperTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/peewee.py", line 2223, in execute_sql
    res = cursor.execute(sql, params or ())
sqlite3.OperationalError: database table is locked

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/tests.py", line 1234, in tearDown
    drop_tables(self.requires)
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/tests.py", line 392, in drop_tables
    model.drop_table(True)
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/peewee.py", line 2873, in drop_table
    cls._meta.database.drop_table(cls, fail_silently, cascade)
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/peewee.py", line 2314, in drop_table
    model_class, fail_silently, cascade))
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/peewee.py", line 2232, in execute_sql
    self.commit()
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/peewee.py", line 2104, in __exit__
    reraise(new_type, new_type(*exc_value.args), traceback)
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/peewee.py", line 93, in reraise
    raise value.with_traceback(tb)
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/peewee.py", line 2223, in execute_sql
    res = cursor.execute(sql, params or ())
peewee.OperationalError: database table is locked

======================================================================
ERROR: test_tuples_dicts (tests.QueryResultWrapperTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/peewee.py", line 2223, in execute_sql
    res = cursor.execute(sql, params or ())
sqlite3.OperationalError: database table is locked

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/tests.py", line 1230, in setUp
    drop_tables(self.requires)
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/tests.py", line 392, in drop_tables
    model.drop_table(True)
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/peewee.py", line 2873, in drop_table
    cls._meta.database.drop_table(cls, fail_silently, cascade)
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/peewee.py", line 2314, in drop_table
    model_class, fail_silently, cascade))
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/peewee.py", line 2232, in execute_sql
    self.commit()
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/peewee.py", line 2104, in __exit__
    reraise(new_type, new_type(*exc_value.args), traceback)
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/peewee.py", line 93, in reraise
    raise value.with_traceback(tb)
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/peewee.py", line 2223, in execute_sql
    res = cursor.execute(sql, params or ())
peewee.OperationalError: database table is locked

======================================================================
ERROR: test_failure (tests.TestSavepoints)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/tests.py", line 3863, in test_failure
    ValueError, self._outer, fail_outer=True, fail_inner=True)
  File "/usr/lib64/python3.3/unittest/case.py", line 570, in assertRaises
    return context.handle('assertRaises', callableObj, args, kwargs)
  File "/usr/lib64/python3.3/unittest/case.py", line 135, in handle
    callable_obj(*args, **kwargs)
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/tests.py", line 3822, in _outer
    with test_db.savepoint():
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/peewee.py", line 2351, in savepoint
    return savepoint_sqlite(self, sid)
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/peewee.py", line 2519, in __init__
    self.sid = sid or 's' + uuid.uuid4().get_hex()
AttributeError: 'UUID' object has no attribute 'get_hex'

======================================================================
ERROR: test_inner_failure (tests.TestSavepoints)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/tests.py", line 3849, in test_inner_failure
    self._outer(fail_inner=True)
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/tests.py", line 3822, in _outer
    with test_db.savepoint():
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/peewee.py", line 2351, in savepoint
    return savepoint_sqlite(self, sid)
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/peewee.py", line 2519, in __init__
    self.sid = sid or 's' + uuid.uuid4().get_hex()
AttributeError: 'UUID' object has no attribute 'get_hex'

======================================================================
ERROR: test_outer_failure (tests.TestSavepoints)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/tests.py", line 3857, in test_outer_failure
    self.assertRaises(ValueError, self._outer, fail_outer=True)
  File "/usr/lib64/python3.3/unittest/case.py", line 570, in assertRaises
    return context.handle('assertRaises', callableObj, args, kwargs)
  File "/usr/lib64/python3.3/unittest/case.py", line 135, in handle
    callable_obj(*args, **kwargs)
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/tests.py", line 3822, in _outer
    with test_db.savepoint():
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/peewee.py", line 2351, in savepoint
    return savepoint_sqlite(self, sid)
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/peewee.py", line 2519, in __init__
    self.sid = sid or 's' + uuid.uuid4().get_hex()
AttributeError: 'UUID' object has no attribute 'get_hex'

======================================================================
ERROR: test_success (tests.TestSavepoints)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/tests.py", line 3843, in test_success
    self._outer()
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/tests.py", line 3822, in _outer
    with test_db.savepoint():
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/peewee.py", line 2351, in savepoint
    return savepoint_sqlite(self, sid)
  File "/mnt/gen2/TmpDir/portage/dev-python/peewee-2.2.1/work/peewee-2.2.1/peewee.py", line 2519, in __init__
    self.sid = sid or 's' + uuid.uuid4().get_hex()
AttributeError: 'UUID' object has no attribute 'get_hex'

----------------------------------------------------------------------
Ran 168 tests in 186.719s

FAILED (errors=7)
TESTING USING PYTHON 3.3.5 (default, Apr 23 2014, 10:45:31) 
[GCC 4.8.2]
SQLITE VERSION: 2.6.0
Skipping "for update" tests
Skipping "sequence" tests
Skipping "foreign key" tests
Skipping "drop/cascade" tests
Skipping "window function" tests
Adding tests for "tests"
```

Under py3.4, it yielded
FAILED (errors=6). Not much in it.
Do you require anything further?

On the presumption peewee is not intended to support py3, please cancel the above.


I run continuous integration with python versions 2.6, 2.7, 3.2 and 3.3 and both sqlite and postgresql backends. All appear to be passing:

https://travis-ci.org/coleifer/peewee


On current Gentoo (unstable), I observe the same test failures and output as idella attached above when running `PEEWEE_TEST_BACKEND=sqlite python runtests.py` under Python 3.3.5, and also the same (apart from test_tuples_dicts which does not fail) under Python 3.4.0. Adding the '-a' switch, as per .travis.yml yields `ImportError: No module named 'StringIO'`.


ok with a prompt from eroen, it came to my attention that 2.2.1 is in fact an old release.  How this came about is frankly an unhelpful factor here.  Suffice to say we figured it.  Now have a 2.2.4 passing the testsuite under all pythons


Glad you have 2.2.4 passing, sorry for the confusion this must have caused.