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

Move test sub-packages to Lib/test #54781

Open
voidspace opened this issue Nov 29, 2010 · 72 comments
Open

Move test sub-packages to Lib/test #54781

voidspace opened this issue Nov 29, 2010 · 72 comments
Labels
3.12 easy tests type-feature

Comments

@voidspace
Copy link
Contributor

@voidspace voidspace commented Nov 29, 2010

BPO 10572
Nosy @warsaw, @brettcannon, @theller, @rhettinger, @terryjreedy, @abalkin, @benjaminp, @tarekziade, @ned-deily, @ezio-melotti, @merwok, @bitdancer, @voidspace, @berkerpeksag, @zware, @serhiy-storchaka, @pablogsal, @miss-islington, @erlend-aasland, @Leonardofreua
PRs
  • #18524
  • #18727
  • #24148
  • #29304
  • #29327
  • Files
  • issue10572-sqlite3.patch
  • issue10572-lib2to3.patch
  • issue10572-sqlite3-2.patch
  • issue10572-lib2to3-2.patch
  • issue10572-sqlite3.diff
  • issue10572-ctypes.diff
  • 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 = None
    closed_at = None
    created_at = <Date 2010-11-29.00:52:57.129>
    labels = ['easy', 'type-feature', 'tests', '3.9']
    title = 'Move test sub-packages to Lib/test'
    updated_at = <Date 2021-11-16.14:13:17.853>
    user = 'https://github.com/voidspace'

    bugs.python.org fields:

    activity = <Date 2021-11-16.14:13:17.853>
    actor = 'erlendaasland'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Tests']
    creation = <Date 2010-11-29.00:52:57.129>
    creator = 'michael.foord'
    dependencies = []
    files = ['29204', '29209', '29249', '29250', '36316', '36317']
    hgrepos = []
    issue_num = 10572
    keywords = ['patch', 'easy']
    message_count = 58.0
    messages = ['122751', '122815', '122817', '122818', '122820', '122828', '122830', '122838', '122841', '122847', '122852', '127032', '179583', '179587', '179588', '179589', '179596', '182809', '182822', '182913', '182926', '182952', '182954', '182982', '183074', '183078', '183087', '224186', '224299', '224342', '225079', '225083', '360661', '361240', '361325', '361401', '361446', '362090', '362101', '362844', '363106', '364232', '364233', '364248', '364312', '364357', '364358', '364359', '364448', '364827', '389357', '397580', '397649', '405031', '405351', '405422', '405423', '406404']
    nosy_count = 23.0
    nosy_names = ['barry', 'brett.cannon', 'theller', 'rhettinger', 'terry.reedy', 'ghaering', 'belopolsky', 'benjamin.peterson', 'tarek', 'gpolo', 'ned.deily', 'ezio.melotti', 'eric.araujo', 'r.david.murray', 'michael.foord', 'berker.peksag', 'zach.ware', 'serhiy.storchaka', 'gmwils', 'pablogsal', 'miss-islington', 'erlendaasland', 'Leonardofreua']
    pr_nums = ['18524', '18727', '24148', '29304', '29327']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue10572'
    versions = ['Python 3.9']

    @voidspace
    Copy link
    Contributor Author

    @voidspace voidspace commented Nov 29, 2010

    Having tests in Lib/test instead of inside the package makes it easier to grep the unittest package without grepping the tests. The Windows installer has an "install without tests" option which is easier to honour if the tests aren't in the package.

    However, currently all packages that have test *packages* have the tests in the package rather than inside Lib/test. (There are no test packages inside Lib/test.)

    Examples: email, distutils, ctypes, importlib, json, lib2to3, sqlite3

    I also maintain an external port of unittest from Python 3. This is unittest2-py3k. Moving the tests would make it *slightly* harder to keep this in sync. I'm moving to maintaining this port as a set of patches rather than a separate branch. These patches can be applied automatically to unittest from py3k head. unittest2-py3k will be built automatically by a script, so it isn't a big deal.

    @voidspace voidspace added the type-bug label Nov 29, 2010
    @voidspace voidspace self-assigned this Nov 29, 2010
    @voidspace voidspace added the easy label Nov 29, 2010
    @ezio-melotti
    Copy link
    Member

    @ezio-melotti ezio-melotti commented Nov 29, 2010

    3.1 should also be considered if the tests are moved. In theory this is not a bug fix so it shouldn't go in 3.1, but in practice it will make merging more difficult. This might not be a strong argument though, considering that 3.1 will accept only security fixes soon and only the few developers that work on unittest will be affected.

    @voidspace
    Copy link
    Contributor Author

    @voidspace voidspace commented Nov 29, 2010

    The same is true for 2.7 though, and that is getting bug fixes. svnmerge would no longer work (and to making the change would mean moving the tests in a point release).

    @abalkin
    Copy link
    Member

    @abalkin abalkin commented Nov 29, 2010

    +0, and I think we should hear from the maintainers of the affected packages first. For packages that are also externally maintained moving tests out may cause inconvenience to the maintainer.

    @voidspace
    Copy link
    Contributor Author

    @voidspace voidspace commented Nov 29, 2010

    That list of examples was non-exhaustive, there is also tkinter.

    @bitdancer
    Copy link
    Member

    @bitdancer bitdancer commented Nov 29, 2010

    For the email package I would be in favor of moving the tests to Lib/test. I've always found it a bit inconvenient that they are in Lib/email. After hearing of Michael's intent with unittest, and given the evolution of email5 into email5.1, I am also considering the possibility of packaging email6 (when I get to it!) as a patch set against email5, which would make this change less of an issue for email6 development.

    The 2.7 sync issue is a concern, but there are certainly precedents for differing file layouts between 3.x and 2.7. I'm willing myself to deal with this for email.

    Barry may have a different opinion.

    All of that said, this is a general enough issue that it may be appropriate to raise it on python-dev. Even if exceptions are made for individual packages, it would be good to agree on a general "best practices" rule for this for the stdlib.

    @warsaw
    Copy link
    Member

    @warsaw warsaw commented Nov 29, 2010

    grepping the code without the tests doesn't seem that compelling a use case to me, given that grep and find both provide options to prune directories. I do think that moving the tests out of the email package will make it harder to maintain and distribute as a separate package. However, if RDM thinks the burden won't be too high, and the advantages of a split outweigh the disadvantages, then I defer to him. I would still make a case for distributing email6 as a package available on Cheeseshop though, otherwise it just won't get much independent use until it's in the stdlib.

    @bitdancer
    Copy link
    Member

    @bitdancer bitdancer commented Nov 29, 2010

    Yes, a cheeseshop package is definitely part of the plan, I didn't mean to imply otherwise. It won't be hard to automate the packaging, and indeed I'll wind up doing that anyway even if the tests stay inside Lib/email.

    I will say that that I'm probably only +0.5 on this change...I like it from a consistency standpoint (heading toward all stdlib tests being in Lib/test) and it seems like it would make the job of packagers who desire a 'no tests' option easier. But things have been working fine as they are, which is why I'm not at a full +1 :).

    @merwok
    Copy link
    Member

    @merwok merwok commented Nov 29, 2010

    For distutils tests, I’m ±0. I don’t see any major drawback nor any major benefit. Tarek will decide.

    @rhettinger
    Copy link
    Contributor

    @rhettinger rhettinger commented Nov 29, 2010

    Of those, it makes the most sense to move the json tests to Lib/tests. Bob is not externally maintaining the 3.x version. It's all our now.

    Also, it looks like importlib is in a maintenance mode now.

    There is merit to keeping 2to3, ctypes, sqlite tests separate.

    Currently all of the documentation files are still under Doc so we should keep it that way and not move them under package directory trees.

    @brettcannon
    Copy link
    Member

    @brettcannon brettcannon commented Nov 29, 2010

    I have no issue with moving importlib into Lib/test as long as I can still run the tests with python3 -m test.importlib. I actually only put the tests in importlib.tests because that was common practice amongst newer packages in the stdlib.

    And just to prevent some rumour from perpetuating, importlib is not in maintenance mode. In fact the API was heavily reworked in 3.2 and I plan on exposing more of the API publicly in 3.3 and hopefully to bootstrap as well. The only thing you could think is in maintenance mode is importlib's Chesseshop package, but that's just for 2.x compatibility and for Django's benefit.

    @abalkin
    Copy link
    Member

    @abalkin abalkin commented Jan 25, 2011

    Changing the title to reflect broader scope of this issue. Json tests were moved to Lib/test/json_tests in r86875.

    @abalkin abalkin changed the title Move unittest test package to Lib/test Move test sub-packages to Lib/test Jan 25, 2011
    @bitdancer
    Copy link
    Member

    @bitdancer bitdancer commented Jan 10, 2013

    I believe that the complete list of test files still located outside of Lib/test are:

    tkinter/test
    distutils/tests
    ctypes/tests
    lib2to3/tests
    sqlite3/test
    unittest/test

    That last is somewhat ironic since Michael opened the issue :).

    I'm considering working on some of the uncommitted patches for sqlite3, so I may take on moving those tests.

    @bitdancer bitdancer added tests type-feature and removed type-bug labels Jan 10, 2013
    @bitdancer
    Copy link
    Member

    @bitdancer bitdancer commented Jan 10, 2013

    Talked to Michael in IRC. He isn't particularly in favor of the move of the unittest tests, but doesn't object if someone else wants to do it. So, unassigning the issue from him.

    @abalkin
    Copy link
    Member

    @abalkin abalkin commented Jan 10, 2013

    ctypes/tests is within my area of interests and may prove to be one of the harder pieces. I'll try to move it and report the results. I have not worked with the rest, so unless it is truly trivial this will have to wait for another volunteer.

    @benjaminp
    Copy link
    Contributor

    @benjaminp benjaminp commented Jan 10, 2013

    I honestly don't see the point of moving tests around.

    @brettcannon
    Copy link
    Member

    @brettcannon brettcannon commented Jan 10, 2013

    Two reasons for collecting all of the tests in a single location:

    1. Facilitates test discovery
    2. It makes packaging of CPython easier for Linux distros that prefer to leave the tests out of the core package

    @gmwils
    Copy link
    Mannequin

    @gmwils gmwils mannequin commented Feb 23, 2013

    Patch attached to move sqlite3 tests under Lib/test, and remove Lib/test/test_sqlite.py.

    Naming of files has been kept the same in the move from Lib/sqlite/test, to allow for easier merging of future patches.

    @gmwils
    Copy link
    Mannequin

    @gmwils gmwils mannequin commented Feb 23, 2013

    Patch attached to move Lib/lib2to3/tests to Lib/test/test_lib2to3.

    @ezio-melotti
    Copy link
    Member

    @ezio-melotti ezio-melotti commented Feb 25, 2013

    Naming of files has been kept the same in the move from
    Lib/sqlite/test, to allow for easier merging of future patches.

    This should be done with "hg mv" -- this will also allow to change the name while preserving the history if that's desirable.

    @gmwils
    Copy link
    Mannequin

    @gmwils gmwils mannequin commented Feb 25, 2013

    The move will need to be done by someone with commit access. These patches came from using hg mv.

    After doing the move, there is some cleanup needed in each. These changes are included in the attached patches.

    @merwok
    Copy link
    Member

    @merwok merwok commented Feb 25, 2013

    Mercurial’s diff formats are actually able to represent file creation, deletion and rename.

    @vstinner
    Copy link
    Member

    @vstinner vstinner commented Jun 20, 2022

    I created issue #93839 which is basically a duplicate of this issue.

    @erlend-aasland
    Copy link
    Contributor

    @erlend-aasland erlend-aasland commented Jun 20, 2022

    Let's close either this issue or #93839 then.

    @erlend-aasland erlend-aasland added the pending label Jun 20, 2022
    @vstinner
    Copy link
    Member

    @vstinner vstinner commented Jun 21, 2022

    I closed #93839 as duplicate of this issue.

    @erlend-aasland erlend-aasland removed the pending label Jun 21, 2022
    @erlend-aasland
    Copy link
    Contributor

    @erlend-aasland erlend-aasland commented Jun 21, 2022

    The following tests have now been moved by Victor:

    There are three to go:

    $ ls -1d Lib/*/test{s,}
    Lib/distutils/tests
    Lib/lib2to3/tests
    Lib/tkinter/test

    vstinner added a commit to vstinner/cpython that referenced this issue Jun 21, 2022
    @vstinner
    Copy link
    Member

    @vstinner vstinner commented Jun 21, 2022

    PR to lib2to3: #94049

    @vstinner
    Copy link
    Member

    @vstinner vstinner commented Jun 21, 2022

    Lib/distutils/tests

    The whole Lib/distutils/ directory should be removed in Python 3.12, so maybe we can just wait until it's removed.

    @tiran tiran added 3.12 and removed 3.9 labels Jun 21, 2022
    vstinner added a commit to vstinner/cpython that referenced this issue Jun 21, 2022
    * Add Lib/test/test_ttk/__init__.py based on test_ttk_guionly.py.
    * Remove Lib/test/test_ttk_guionly.py.
    vstinner added a commit that referenced this issue Jun 21, 2022
    * Move Lib/lib2to3/tests/ to Lib/test/test_lib2to3/.
    * Remove Lib/test/test_lib2to3.py.
    * Update imports.
    * all_project_files(): use different paths and sort files
      to make the tests more reproducible.
    * Update references to tests.
    @vstinner
    Copy link
    Member

    @vstinner vstinner commented Jun 21, 2022

    PR to lib2to3: #94049

    Merged: 616fa34

    vstinner added a commit to vstinner/cpython that referenced this issue Jun 21, 2022
    * Add Lib/test/test_ttk/__init__.py based on test_ttk_guionly.py.
    * Remove Lib/test/test_ttk_guionly.py.
    @vstinner
    Copy link
    Member

    @vstinner vstinner commented Jun 21, 2022

    tkinter/ttk: I created PR #94070.

    vstinner added a commit to vstinner/cpython that referenced this issue Jun 21, 2022
    * Add Lib/test/test_ttk/__init__.py based on test_ttk_guionly.py.
    * Remove Lib/test/test_ttk_guionly.py.
    @brettcannon
    Copy link
    Member

    @brettcannon brettcannon commented Jun 21, 2022

    • Lib/ctypes/test/
    • Lib/distutils/tests/ (slated for removal in 3.12)
    • Lib/idlelib/idle_test/ (request to leave in place)
    • Lib/lib2to3/tests/
    • Lib/tkinter/test/ (PR)
    • Lib/unittest/test/

    @terryjreedy
    Copy link
    Member

    @terryjreedy terryjreedy commented Jun 21, 2022

    As I have requested before, and as more or less agreed to, please remove idlelib from this list.
    #54781 (comment)
    Note: 'idlelib.idle_test' appears 122 times in idlelib. About 40% of the occurrences, the directory, and at least one of its files, should remain in any case.

    @merwok
    Copy link
    Member

    @merwok merwok commented Jun 22, 2022

    Brett, I take it that the checkmarck for distutils tests means these are ok to leave as is, not move!

    vstinner added a commit to vstinner/cpython that referenced this issue Jun 22, 2022
    * Add Lib/test/test_ttk/__init__.py based on test_ttk_guionly.py.
    * Remove Lib/test/test_ttk_guionly.py.
    @brettcannon
    Copy link
    Member

    @brettcannon brettcannon commented Jun 22, 2022

    @merwok that was my intent. As @vstinner pointed out earlier, with distutils on its way out I don't think it's worth the effort.

    vstinner added a commit that referenced this issue Jun 22, 2022
    * Move Lib/tkinter/test/test_tkinter/ to Lib/test/test_tkinter/.
    * Move Lib/tkinter/test/test_ttk/ to Lib/test/test_ttk/.
    * Add Lib/test/test_ttk/__init__.py based on test_ttk_guionly.py.
    * Add Lib/test/test_tkinter/__init__.py
    * Remove old Lib/test/test_tk.py.
    * Remove old Lib/test/test_ttk_guionly.py.
    * Add __main__ sub-modules.
    * Update imports and update references to rename files.
    vstinner added a commit to vstinner/cpython that referenced this issue Jun 22, 2022
    @vstinner
    Copy link
    Member

    @vstinner vstinner commented Jun 22, 2022

    I created PR #94145 for IDLE tests, even if @terryjreedy asked to not move them. I would prefer to move the tests, but I will follow Terry's decision, he maintains IDLE. I wrote a PR to see the consequences of moving tests. See my comment in the PR.

    @vstinner
    Copy link
    Member

    @vstinner vstinner commented Jun 22, 2022

    Lib/idlelib/idle_test/ is the last Lib/ sub-directory which contains tests which are not under Lib/test/. I wait for @terryjreedy's last word on my PR #94145 to see if we move IDLE tests, or if we leave tests there and just close the issue.

    vstinner added a commit to vstinner/cpython that referenced this issue Jun 23, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.12 easy tests type-feature
    Projects
    None yet
    Development

    No branches or pull requests