Zope testrunner coverage - works or not ?

Issue #934 resolved
Former user created an issue

I am working on collective.rope (integration of SQLAlchemy and Zope2).

When running test coverage with 0.4.1, I get relevant results.

When running test coverage with 0.4.2p3, only the lines defining classes or functions are mentioned as run. IOW, only the import of my files is 'covered'.

Godefroid Chapelle gotcha@bubblenet.be

Comments (9)

  1. Mike Bayer repo owner
    • changed component to tests
    • assigned issue to
    • changed milestone to 0.4.3

    assigning to jek - jek did we move around the relationship of imports vs. when coverage is imported/switched on ? i forget the exact mechanics of this issue but its related to that.

  2. jek

    Can't replicate this on 0.4.2p3 or trunk. --coverage seems to be working fine for me. (below.) The trunk has some changes that would effect an external user of of testlib, but those aren't in p3.

    rel_0_4_2p3$ python test/dialect/sqlite.py --coverage
    test_extra_reserved_words (__main__.DialectTest) ... ok
    test_quoted_identifiers (__main__.DialectTest) ... ok
    test_empty_insert_nopk1 (__main__.InsertTest) ... ok
    test_empty_insert_nopk2 (__main__.InsertTest) ... ok
    test_empty_insert_pk1 (__main__.InsertTest) ... ok
    test_empty_insert_pk2 (__main__.InsertTest) ... ok
    test_empty_insert_pk3 (__main__.InsertTest) ... ok
    test_empty_insert_pk4 (__main__.InsertTest) ... ok
    test_inserts_with_spaces (__main__.InsertTest) ... ok
    test_date (__main__.TestTypes) ... ok
    
    ----------------------------------------------------------------------
    Ran 10 tests in 0.372s
    
    OK
    
    Preparing coverage report...
    Name                                          Stmts   Exec  Cover
    -----------------------------------------------------------------
    lib/sqlalchemy/__init__                           7      7   100%
    lib/sqlalchemy/databases/__init__                 1      1   100%
    lib/sqlalchemy/databases/access                 268      0     0%
    lib/sqlalchemy/databases/firebird               258      0     0%
    lib/sqlalchemy/databases/information_schema      77      0     0%
    lib/sqlalchemy/databases/informix               315      0     0%
    lib/sqlalchemy/databases/maxdb                  590      0     0%
    lib/sqlalchemy/databases/mssql                  616      0     0%
    lib/sqlalchemy/databases/mxODBC                  31      0     0%
    lib/sqlalchemy/databases/mysql                 1013      0     0%
    lib/sqlalchemy/databases/oracle                 449      0     0%
    lib/sqlalchemy/databases/postgres               454      0     0%
    lib/sqlalchemy/databases/sqlite                 281    204    72%
    lib/sqlalchemy/databases/sybase                 464      0     0%
    lib/sqlalchemy/engine/__init__                   26     13    50%
    lib/sqlalchemy/engine/base                      831    415    49%
    lib/sqlalchemy/engine/default                   235    137    58%
    lib/sqlalchemy/engine/strategies                108     77    71%
    lib/sqlalchemy/engine/threadlocal               133     49    36%
    lib/sqlalchemy/engine/url                        92     41    44%
    lib/sqlalchemy/exceptions                        46     27    58%
    lib/sqlalchemy/ext/__init__                       0      0   100%
    lib/sqlalchemy/ext/activemapper                 179      0     0%
    lib/sqlalchemy/ext/assignmapper                  52      0     0%
    lib/sqlalchemy/ext/associationproxy             448      0     0%
    lib/sqlalchemy/ext/orderinglist                  75      0     0%
    lib/sqlalchemy/ext/selectresults                 19      0     0%
    lib/sqlalchemy/ext/sessioncontext                28      0     0%
    lib/sqlalchemy/ext/sqlsoup                      140      0     0%
    lib/sqlalchemy/interfaces                         4      0     0%
    lib/sqlalchemy/logging                           47     25    53%
    lib/sqlalchemy/mods/__init__                      0      0   100%
    lib/sqlalchemy/mods/selectresults                 5      0     0%
    lib/sqlalchemy/orm/__init__                      84      0     0%
    lib/sqlalchemy/orm/attributes                   735      0     0%
    lib/sqlalchemy/orm/collections                  608      0     0%
    lib/sqlalchemy/orm/dependency                   315      0     0%
    lib/sqlalchemy/orm/dynamic                      121      0     0%
    lib/sqlalchemy/orm/interfaces                   210      0     0%
    lib/sqlalchemy/orm/mapper                       908      0     0%
    lib/sqlalchemy/orm/properties                   513      0     0%
    lib/sqlalchemy/orm/query                        661      0     0%
    lib/sqlalchemy/orm/scoping                      100      0     0%
    lib/sqlalchemy/orm/session                      441      0     0%
    lib/sqlalchemy/orm/shard                         72      0     0%
    lib/sqlalchemy/orm/strategies                   472      0     0%
    lib/sqlalchemy/orm/sync                         119      0     0%
    lib/sqlalchemy/orm/unitofwork                   489      0     0%
    lib/sqlalchemy/orm/uowdumper                    130      0     0%
    lib/sqlalchemy/orm/util                         184      0     0%
    lib/sqlalchemy/pool                             429    193    44%
    lib/sqlalchemy/queue                             94     23    24%
    lib/sqlalchemy/schema                           613    328    53%
    lib/sqlalchemy/sql/__init__                       2      2   100%
    lib/sqlalchemy/sql/compiler                     604    322    53%
    lib/sqlalchemy/sql/expression                  1629    685    42%
    lib/sqlalchemy/sql/functions                     59     40    67%
    lib/sqlalchemy/sql/operators                     52     29    55%
    lib/sqlalchemy/sql/util                         131     30    22%
    lib/sqlalchemy/sql/visitors                      64     30    46%
    lib/sqlalchemy/topological                      175     57    32%
    lib/sqlalchemy/types                            415    169    40%
    lib/sqlalchemy/util                             575    227    39%
    -----------------------------------------------------------------
    TOTAL                                         18296   3131    17%
    

    ...and lib/sqlalchemy/databases/sqlite.py,cover shows the regular execution path covered.

  3. Former user Account Deleted

    I am not speaking of coverage of sqlalchemy itself.

    I mean that I cannot test coverage of my own code when it works with 0.4.2p3 even though I can test coverage of my own code with 0.4.1.

  4. Former user Account Deleted

    I am using Zope testrunner,

    http://svn.zope.org/zope.testing/branches/Zope-3.3/src/zope/testing/testrunner.py?rev=69670&view=markup

    In the given module, I found the following code :

    class TestTrace(trace.Trace):
        """Simple tracer.
    
        >>> tracer = TestTrace(None, count=False, trace=False)
    
        Simple rules for use: you can't stop the tracer if it not started
        and you can't start the tracer if it already started:
    
        >>> tracer.stop()
        Traceback (most recent call last):
            File 'testrunner.py'
        AssertionError: can't stop if not started
    
        >>> tracer.start()
        >>> tracer.start()
        Traceback (most recent call last):
            File 'testrunner.py'
        AssertionError: can't start if already started
    
        >>> tracer.stop()
        >>> tracer.stop()
        Traceback (most recent call last):
            File 'testrunner.py'
        AssertionError: can't stop if not started
        """
    
        def __init__(self, options, **kw):
            trace.Trace.__init__(self, **kw)
            if options is not None:
                self.ignore = TestIgnore(options)
            self.started = False
    
        def start(self):
            assert not self.started, "can't start if already started"
            if not self.donothing:
                sys.settrace(self.globaltrace)
                threading.settrace(self.globaltrace)
            self.started = True
    
        def stop(self):
            assert self.started, "can't stop if not started"
            if not self.donothing:
                sys.settrace(None)
                threading.settrace(None)
            self.started = False
    
  5. jek
    • removed milestone

    i haven't be able to replicate any issues with coverage, so i'm putting this on hold for the moment. i'd be happy to dig into it with a collective.rope checkout- i'd just need some pointers on how to set that up that environment.

  6. Log in to comment