1. Michael Bayer
  2. sqlalchemy
  3. Issues

Issues

Issue #3144 resolved

__reduce__ failure in _defer_name(), misnamed test

idella5
created an issue

This single failure occurs under pythons 2.7 3.2, 3.3 3.4 & pypy. Here is the traceback under pypy;

....E...................................................SSSSSSSS...............
=================================================================
ERROR: test.sql.test_types.PickleMetadataTest.testmeta
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/pypy/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/mnt/gen2/TmpDir/portage/dev-python/sqlalchemy-0.9.7/work/SQLAlchemy-0.9.7-pypy/test/sql/test_types.py", line 260, in testmeta
    loads(dumps(column_type))
  File "/usr/lib64/pypy/lib_pypy/cPickle.py", line 600, in loads
    return Unpickler(f).load()
  File "/usr/lib64/pypy/lib_pypy/cPickle.py", line 170, in load
    self.dispatch[key](self)
  File "/usr/lib64/pypy/lib_pypy/cPickle.py", line 439, in load_reduce
    value = self.stack[-1](*args)
TypeError: __new__() takes exactly 2 arguments (3 given)

----------------------------------------------------------------------
Ran 5926 tests in 705.219s

FAILED (SKIP=221, errors=1)

and under py3.4;

===============================================================
ERROR: test.sql.test_types.PickleMetadataTest.testmeta
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python3.4/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/mnt/gen2/TmpDir/portage/dev-python/sqlalchemy-0.9.7/work/SQLAlchemy-0.9.7-python3_4/test/sql/test_types.py", line 260, in testmeta
    loads(dumps(column_type))
TypeError: __new__() takes 2 positional arguments but 3 were given

----------------------------------------------------------------------
Ran 5960 tests in 162.581s

FAILED (SKIP=193, errors=1)

errors=1 out of 5960 tests is a fine job any day of the week. The no. or args appears a triviality. Do you require anything further

Comments (23)

  1. Nils Philippsen

    This bug was introduced with commit d462dbde99762bfbdc4d4af7f67c329350a8700a, more precisely with _defer_name.__new__() accepting only one parameter:

    class _defer_name(_truncated_label):
        """mark a name as 'deferred' for the purposes of automated name
        generation.
    
        """
        def __new__(cls, value):
    ...
    

    If __new__() also eats additional parameters, the test runs fine:

    class _defer_name(_truncated_label):
        """mark a name as 'deferred' for the purposes of automated name
        generation.
    
        """
        def __new__(cls, value, *rest):
    ...
    

    Someone who knows better than I should look at this though, I don't know where the additional parameter originates (and if the issue rather should be fixed there).

  2. Michael Bayer repo owner

    ah. well here's the first problem:

    diff --git a/test/sql/test_types.py b/test/sql/test_types.py
    index e2d3479..827a9a8 100644
    --- a/test/sql/test_types.py
    +++ b/test/sql/test_types.py
    @@ -234,7 +234,7 @@ class TypeAffinityTest(fixtures.TestBase):
    
     class PickleMetadataTest(fixtures.TestBase):
    
    -    def testmeta(self):
    +    def test_meta(self):
             for loads, dumps in picklers():
                 column_types = [
                     Column('Boo', Boolean()),
    
  3. idella5 reporter

    thanks Mike. First class timing, first class response. My only concern is how you didn't get those failures in your own initial testing.

    Ran 5960 tests in 160.298s

    OK (SKIP=192)

  4. idella5 reporter

    hmm $ PYTHONPATH=. py.test test yielded == 5807 passed, 740 skipped in 243.77 seconds == as opposed to above.

    What is your recommended mode of running? python sqla_nose.py OR py.test test ? Looking like both are about equal

  5. Michael Bayer repo owner

    i was wondering if py.test vs. nose had more issues of this nature. you have the sqla_nose count at 5960 and py.test at 5807? that doesn't really sound right.

  6. Michael Bayer repo owner

    I'm pretty sure there's a regular reason for this, the py.test system I came up with does discovery differently and it also generates new tests that the nose approach does not (you'll see a difference in names). but aggregate number of tests on a default sqlite run is less so I think i need to grep the lists out and compare just to make sure we aren't missing somehting.

    Ran 5874 tests in 119.914s
    
    OK (SKIP=177)
    
     5775 passed, 669 skipped in 173.47 seconds =
    
  7. Michael Bayer repo owner

    basically it seems like nose reports the wrong number at the end. I'm attaching a.txt, which is the nose run with the names normalized, and b.txt which is the pytest run with the names normalized. The number of tests run in both is 5775:

    classics-MacBook-Pro-2:Desktop classic$ cat a.txt | grep -v SKIP | wc -l
        5775
    classics-MacBook-Pro-2:Desktop classic$ cat b.txt | grep -v SKIP | wc -l
        5775
    classics-MacBook-Pro-2:Desktop classic$ cat a.txt | grep SKIP | wc -l
         177
    classics-MacBook-Pro-2:Desktop classic$ cat b.txt | grep SKIP | wc -l
         669
    

    The skips are counted differently in that nose does per-suite skips as one skip and pytest does not. I have no idea what 5874 is, I have a feeling nose is counting things that my own nose plugin reports as "not a test".

  8. Nils Philippsen

    So is py.test the recommended way of testing? If so, I could get rid of the patch against sqla_nose.py in the Fedora packages which makes it test the code in build/ instead of what is installed.

  9. Michael Bayer repo owner

    py.test is currently the new "standard", based on the nose developers said they were no longer supporting nose and the "2.0" version has been stalled. py.test gives me a lot more capabilities in controlling how tests are discovered and run (things that nose could do also if they were still developing it).

  10. Michael Bayer repo owner

    though that lib thing you mention in sqla_nose, maybe there's a way that could detect if "python setup.py test" were being run and adjust the path accordingly.

  11. Log in to comment