Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests to verify API match of modules with 2 implementations #54068

Closed
stutzbach mannequin opened this issue Sep 15, 2010 · 16 comments
Closed

Add tests to verify API match of modules with 2 implementations #54068

stutzbach mannequin opened this issue Sep 15, 2010 · 16 comments
Assignees
Labels
tests Tests in the Lib/test dir type-feature A feature request or enhancement

Comments

@stutzbach
Copy link
Mannequin

stutzbach mannequin commented Sep 15, 2010

BPO 9859
Nosy @brettcannon, @terryjreedy, @gpshead, @abalkin, @pitrou, @merwok, @bitdancer, @berkerpeksag
Files
  • issue9859.patch
  • issue9859_1.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/gpshead'
    closed_at = <Date 2015-04-14.21:39:01.561>
    created_at = <Date 2010-09-15.13:46:35.264>
    labels = ['type-feature', 'tests']
    title = 'Add tests to verify API match of modules with 2 implementations'
    updated_at = <Date 2015-04-14.22:25:19.702>
    user = 'https://bugs.python.org/stutzbach'

    bugs.python.org fields:

    activity = <Date 2015-04-14.22:25:19.702>
    actor = 'python-dev'
    assignee = 'gregory.p.smith'
    closed = True
    closed_date = <Date 2015-04-14.21:39:01.561>
    closer = 'gregory.p.smith'
    components = ['Tests']
    creation = <Date 2010-09-15.13:46:35.264>
    creator = 'stutzbach'
    dependencies = []
    files = ['38993', '39007']
    hgrepos = []
    issue_num = 9859
    keywords = ['patch']
    message_count = 16.0
    messages = ['116445', '116452', '116453', '116752', '221823', '240932', '240938', '240941', '240993', '241002', '241004', '241008', '241012', '241026', '241036', '241046']
    nosy_count = 12.0
    nosy_names = ['brett.cannon', 'terry.reedy', 'gregory.p.smith', 'belopolsky', 'pitrou', 'stutzbach', 'eric.araujo', 'r.david.murray', 'BreamoreBoy', 'python-dev', 'berker.peksag', 'laura']
    pr_nums = []
    priority = 'low'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue9859'
    versions = ['Python 3.5']

    @stutzbach
    Copy link
    Mannequin Author

    stutzbach mannequin commented Sep 15, 2010

    Recently it came to light that the classes in C and Python implementations of the io module have slightly different attributes (bpo-9858). I propose the addition of a helper function in Lib/test/support.py to verify that the classes in two different implementations define the same attributes. Then, we can add tests to use that function to verify that C and Python implementations define the same API (for the io module, but also for other modules where we have two implementations). The script I added to bpo-9858 could serve as a starting point for such a function.

    Since CPython's standard library is the de facto reference implementation, it's important that it define one API and not two slightly different ones. :-)

    @stutzbach stutzbach mannequin added tests Tests in the Lib/test dir type-feature A feature request or enhancement labels Sep 15, 2010
    @bitdancer
    Copy link
    Member

    Shouldn't the test suite catch such discrepancies by testing all of the API? So your script catching something would be the equivalent of "oops, we forgot a test" (or "oops, this name shouldn't be public"). Which is not a bad thing to have as part of the test suite.

    @stutzbach
    Copy link
    Mannequin Author

    stutzbach mannequin commented Sep 15, 2010

    Yes, exactly. :-)

    (see also bpo-9731, which has a similar flavor)

    @terryjreedy
    Copy link
    Member

    +1
    I presume you can use the experience with bpo-9858 to either refine the program to have fewer false positives or refine the program doc to explain the possibility where such are unavoidable. (And as a lint-like metatest, I think false positives are better than false negatives.)

    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jun 28, 2014

    @daniel do you intend putting forward a formal patch on this issue? I'm asking as I think bpo-9858 is effectively completed and I've just asked for a formal patch review on bpo-9731.

    @Laura
    Copy link
    Mannequin

    Laura mannequin commented Apr 14, 2015

    Created a patch to check whether classes define the same attributes.

    This adds a test for RawIOBase, where Python and and C implementations are out of sync, but skips one of the tests as the issue (bpo-9858) is still outstanding.

    @stutzbach
    Copy link
    Mannequin Author

    stutzbach mannequin commented Apr 14, 2015

    With regret, I have not had time to work on patches and am unlikely to have time in the near future.

    @gpshead gpshead self-assigned this Apr 14, 2015
    @berkerpeksag
    Copy link
    Member

    Thanks for the patch! I've reviewed it on Rietveld: http://bugs.python.org/review/9859/

    @Laura
    Copy link
    Mannequin

    Laura mannequin commented Apr 14, 2015

    Thanks Berker!

    I've added some updates to the patch taking your suggestions into account. There is also a change from using "detect_module_matches" to "detect_api_mismatch", as it is a more general (and accurate) description.

    Also, adding tests for the "detect_api_mismatch" helper function.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 14, 2015

    New changeset b42d1f2aa7a2 by Gregory P. Smith in branch 'default':
    bpo-9859: Adds a test.support.detect_api_mismatch function useful to
    https://hg.python.org/cpython/rev/b42d1f2aa7a2

    New changeset 0b6c894c3c96 by Gregory P. Smith in branch 'default':
    bpo-9859: Adds a CPyMatchTest test case to compare the exposed APIs
    https://hg.python.org/cpython/rev/0b6c894c3c96

    @berkerpeksag
    Copy link
    Member

    I've added a couple of comments about the test: http://bugs.python.org/review/9859/

    @gpshead
    Copy link
    Member

    gpshead commented Apr 14, 2015

    Thanks! Patch applied. I reworded one doc string slightly and fixed up a few lines that were longer than 80 characters. Berker's most recent comments are good ones and can be addressed in another patch.

    Laura, can you jump through the https://www.python.org/psf/contrib/contrib-form/ hoop? (it'll add the "*" next to your name in the bug tracker showing the contributor form has been signed)

    Still TODO: fix the actual issue of the APIs being different. (bpo-9858)

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 14, 2015

    New changeset 9903368b9d7b by Gregory P. Smith in branch 'default':
    bpo-9859: rename CPyMatchTest to APIMismatchTest and add @support.cpython_only.
    https://hg.python.org/cpython/rev/9903368b9d7b

    New changeset cbdd56d07123 by Gregory P. Smith in branch 'default':
    bpo-9859: Document test.support.detect_api_mismatch() and simplify its test.
    https://hg.python.org/cpython/rev/cbdd56d07123

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 14, 2015

    New changeset c6df85e1d42e by Gregory P. Smith in branch 'default':
    bpo-9859: Use an expected failure rather than a skip.
    https://hg.python.org/cpython/rev/c6df85e1d42e

    @gpshead gpshead closed this as completed Apr 14, 2015
    @berkerpeksag
    Copy link
    Member

    Thanks :)

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 14, 2015

    New changeset 0316811f33b2 by Gregory P. Smith in branch 'default':
    bpo-9859: add the missing versionadded tag to the documentation.
    https://hg.python.org/cpython/rev/0316811f33b2

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    tests Tests in the Lib/test dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants