see issue 42 #66

Closed
idella opened this Issue Jan 15, 2013 · 3 comments

Projects

None yet

2 participants

@idella
idella commented Jan 15, 2013

It's a worry. A system tester isn't exactly nominated, and each test file clearly isn't designed to run on python testFile, so using py.test as a standin;

Source compiled.

  • Testing of dev-python/logbook-0.4.1 with CPython 2.6...
    ============================= test session starts ==============================
    platform linux2 -- Python 2.6.8 -- pytest-2.3.4
    collected 42 items

logbook/testsuite/test_contextmanager.py ..........................................

========================== 42 passed in 1.40 seconds ===========================
============================= test session starts ==============================
platform linux2 -- Python 2.6.8 -- pytest-2.3.4
collected 65 items

logbook/testsuite/test_regular.py .................................................................

========================== 65 passed in 1.78 seconds ===========================

  • Testing of dev-python/logbook-0.4.1 with CPython 3.1...
    ======================== test session starts =========================
    platform linux2 -- Python 3.1.5 -- pytest-2.3.4
    collected 0 items / 1 errors
    ========================== ERRORS =============================
    __________ ERROR collecting logbook/testsuite/test_contextmanager.py ___________
    /usr/lib64/python3.1/site-packages/py/_path/local.py:520: in pyimport
              __import__(pkgpath.basename)
    
    logbook/init.py:13: in

    from logbook.base import LogRecord, Logger, LoggerGroup, NestedSetup,
    logbook/base.py:23: in
    from logbook._speedups import group_reflected_property,
    _speedups.pyx:1: in init logbook._speedups (logbook/_speedups.c:5032)
    ???
    E NameError: cmp
    ========================= 1 error in 0.06 seconds =====================
    =========================== test session starts =======================
    platform linux2 -- Python 3.1.5 -- pytest-2.3.4
    collected 0 items / 1 errors

============================ ERRORS =============================
______________ ERROR collecting logbook/testsuite/test_regular.py ______________
/usr/lib64/python3.1/site-packages/py/_path/local.py:520: in pyimport

          __import__(pkgpath.basename)

logbook/init.py:13: in
from logbook.base import LogRecord, Logger, LoggerGroup, NestedSetup,
logbook/base.py:23: in
from logbook._speedups import group_reflected_property,
_speedups.pyx:1: in init logbook._speedups (logbook/_speedups.c:5032)
???
E NameError: cmp
======================= 1 error in 0.06 seconds ========================

The above is the output of

            for test in ${PN}/testsuite/test_*.py; do
            PYTHONPATH=. py.test $test
            done

Don't worry, it's the same for py2.7 and py3.2

Point 1. _speedups.pyx:1: in init logbook._speedups (logbook/_speedups.c:5032)
is common to both

Point 2. despite actually removing the _speedups.py, it is still referenced and pulls the test down.

Point 3. There is no possibility of py.test attempting to test "init.py",
note logbook/init.py:13: in in above.

Point 4. The climax. NameError: cmp. This was made an issue a year ago.
Any progress, per chance?

@brainstorm
Collaborator

@idella, the canonical way to run python tests nowadays seems to be "nose", so please try installing nosetests first, and then run it against the testsuite:

pip install nose
nosetests -v -s

All tests pass in my machine(s) when doing so:

(...)
test_encoded_message_unicode_params (logbook.testsuite.test_regular.UnicodeTestCase) ... ok
test_unicode_message_encoded_params (logbook.testsuite.test_regular.UnicodeTestCase) ... ok
test_warning_redirections (logbook.testsuite.test_regular.WarningsCompatTestCase) ... ok

----------------------------------------------------------------------
Ran 103 tests in 3.794s

OK

Reopen the issue if you find further problems.

@brainstorm brainstorm closed this Jan 15, 2013
@idella
idella commented Jan 16, 2013

Point 1.

    testing() {
            pushd $(find build-${PYTHON_ABI}/lib.linux*/ ${PN}) > /dev/null
            for test in ${PN}/testsuite/test_*.py; do
            PYTHONPATH=. nosetests $test
            done
            popd > /dev/null
    }

I substituted py.test with nosetests. We tend to use them almost interchangeably.

Point 2.

Source compiled.

  • Testing of dev-python/logbook-0.4.1 with CPython 2.7...
    ..........................................

    Ran 42 tests in 1.176s

OK

..................................................................

Ran 66 tests in 1.826s

OK

  • Testing of dev-python/logbook-0.4.1 with CPython 3.2...
    E

    ERROR: Failure: NameError (cmp)

    Traceback (most recent call last):
    File "/usr/lib64/python3.2/site-packages/nose/failure.py", line 37, in runTest
    raise self.exc_class(self.exc_val).with_traceback(self.tb)
    File "/usr/lib64/python3.2/site-packages/nose/loader.py", line 390, in loadTestsFromName
    addr.filename, addr.module)
    File "/usr/lib64/python3.2/site-packages/nose/importer.py", line 39, in importFromPath
    return self.importFromDir(dir_path, fqname)
    File "/usr/lib64/python3.2/site-packages/nose/importer.py", line 86, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
    File "/mnt/gen2/TmpDir/portage/dev-python/logbook-0.4.1/work/Logbook-0.4.1/build-3.2/lib.linux-x86_64-3.2/logbook/init.py", line 13, in
    from logbook.base import LogRecord, Logger, LoggerGroup, NestedSetup,
    File "/mnt/gen2/TmpDir/portage/dev-python/logbook-0.4.1/work/Logbook-0.4.1/build-3.2/lib.linux-x86_64-3.2/logbook/base.py", line 23, in
    from logbook._speedups import group_reflected_property,
    File "_speedups.pyx", line 1, in init logbook._speedups (logbook/_speedups.c:5032)
    NameError: cmp

Ran 1 test in 0.008s

FAILED (errors=1)

E

ERROR: Failure: NameError (cmp)

Traceback (most recent call last):
File "/usr/lib64/python3.2/site-packages/nose/failure.py", line 37, in runTest
raise self.exc_class(self.exc_val).with_traceback(self.tb)
File "/usr/lib64/python3.2/site-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib64/python3.2/site-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib64/python3.2/site-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/mnt/gen2/TmpDir/portage/dev-python/logbook-0.4.1/work/Logbook-0.4.1/build-3.2/lib.linux-x86_64-3.2/logbook/init.py", line 13, in
from logbook.base import LogRecord, Logger, LoggerGroup, NestedSetup,
File "/mnt/gen2/TmpDir/portage/dev-python/logbook-0.4.1/work/Logbook-0.4.1/build-3.2/lib.linux-x86_64-3.2/logbook/base.py", line 23, in
from logbook._speedups import group_reflected_property,
File "_speedups.pyx", line 1, in init logbook._speedups (logbook/_speedups.c:5032)
NameError: cmp


Ran 1 test in 0.001s

FAILED (errors=1)

Point 3. Let's go that extra yard and jump directly into the source code

pushd /mnt/gen2/TmpDir/portage/dev-python/logbook-0.4.1/work/Logbook-0.4.1/build-3.2/lib.linux-x86_64-3.2/

lib.linux-x86_64-3.2 # ls
logbook

PYTHONPATH=. nosetests-python3.1 logbook/testsuite/test_regular.py

.......................................................

Ran 55 tests in 1.389s

OK

lib.linux-x86_64-3.2 # PYTHONPATH=. nosetests-python3.2 logbook/testsuite/test_regular.py

E

ERROR: Failure: NameError (cmp)

Traceback (most recent call last):
File "/usr/lib64/python3.2/site-packages/nose/failure.py", line 37, in runTest
raise self.exc_class(self.exc_val).with_traceback(self.tb)
File "/usr/lib64/python3.2/site-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib64/python3.2/site-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib64/python3.2/site-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/mnt/gen2/TmpDir/portage/dev-python/logbook-0.4.1/work/Logbook-0.4.1/build-3.2/lib.linux-x86_64-3.2/logbook/init.py", line 13, in
from logbook.base import LogRecord, Logger, LoggerGroup, NestedSetup,
File "/mnt/gen2/TmpDir/portage/dev-python/logbook-0.4.1/work/Logbook-0.4.1/build-3.2/lib.linux-x86_64-3.2/logbook/base.py", line 23, in
from logbook._speedups import group_reflected_property,
File "_speedups.pyx", line 1, in init logbook._speedups (logbook/_speedups.c:5032)
NameError: cmp


Ran 1 test in 0.001s

FAILED (errors=1)

Well, a taste of success. 3.1 down, 3.2 to go

"All tests pass in my machine(s) when doing so:"

Well, I've seen this before. Inevitably there are underlying diffs between the systems.
Mine is a gentoo python developer system, used for package managing portage.

"if you find further problems." done
"Reopen the issue" damned if I can see that I can do that. In gentoo bugzilla, not a problem.

@brainstorm
Collaborator

No "testing()" function is required, only using nosetests from the logbook directory should be enough since nose iterates over all tests:

$ cd logbook
$ workon py3.1
(py3.1) logbook$ pwd
/home/roman/dev/logbook
logbook$ nosetests -v -s
(...)
----------------------------------------------------------------------
Ran 103 tests in 3.794s
OK

Make sure you have your virtualenv properly configured, it's more reproducible than fiddling with PYTHONPATH in your own custom environment. I replied to issue #42, I'll carry on from that issue, thanks for the heads up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment