Skip to content

Document test.support.script_helper #62776

Closed

Description

@ncoghlan
BPO 18576
Nosy @ncoghlan, @ezio-melotti, @ericsnowcurrently, @vadmium, @serhiy-storchaka, @JulienPalard, @mlouielu
PRs
  • bpo-18576: Add test.support.script_helper documentation #1252
  • Files
  • script_helper-default.patch: All changes needed to move and document script_helper.py
  • issue_18576_second.patch: The second patch with all changes required to script_helper.py and its documentation
  • issue18576_third_try.patch: The third patch, with changes to the documentation to fix the issues presented at the second one's code review.
  • issue18576_move_and_document_script_helper.diff: Moved without legacy alias + full docs
  • issue18576.patch
  • issue18576.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 = None
    closed_at = <Date 2019-09-09.16:28:15.511>
    created_at = <Date 2013-07-28.12:32:44.605>
    labels = ['easy', 'type-feature', 'tests', 'docs']
    title = 'Document test.support.script_helper'
    updated_at = <Date 2019-09-09.16:28:15.507>
    user = 'https://github.com/ncoghlan'

    bugs.python.org fields:

    activity = <Date 2019-09-09.16:28:15.507>
    actor = 'mdk'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-09-09.16:28:15.511>
    closer = 'mdk'
    components = ['Documentation', 'Tests']
    creation = <Date 2013-07-28.12:32:44.605>
    creator = 'ncoghlan'
    dependencies = []
    files = ['33049', '33055', '33057', '33188', '39645', '39827']
    hgrepos = []
    issue_num = 18576
    keywords = ['patch', 'easy']
    message_count = 24.0
    messages = ['193819', '194908', '205635', '205638', '205656', '205661', '205676', '205680', '205681', '205684', '205689', '205746', '206511', '242944', '242946', '243528', '244929', '244936', '244943', '244965', '245921', '245926', '292116', '351521']
    nosy_count = 11.0
    nosy_names = ['ncoghlan', 'ezio.melotti', 'docs@python', 'eric.snow', 'martin.panter', 'serhiy.storchaka', 'seydou', 'Fotis.Koutoulakis', 'bobcatfish', 'mdk', 'louielu']
    pr_nums = ['1252']
    priority = 'normal'
    resolution = 'out of date'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue18576'
    versions = ['Python 3.5']

    Activity

    1. ncoghlan commented on Jul 28, 2013

      @ncoghlan
      ContributorAuthor

      tests.script_helper provides various utilities for sensibly testing scripts in a subprocess. It isn't easy for CPython developers to discover, since it is isn't documented and the file is mixed in with actual tests in the main test directory.

      As discussed in bpo-15494, it should be:

      1. Moved from Lib/test/ to Lib/test/support (and imports in tests adjusted accordingly)
      2. Documented in Doc/library/test.rst

      These changes should be made on both the 3.3 and default branches to avoid spurious merge conflicts.

    2. added
      docs
      tests
      type-feature
      on Jul 28, 2013
    3. seydou commented on Aug 11, 2013

      seydoumannequin
      Mannequin

      Since I am already on bugs.python.org/issue18578 I will tackle this issue, if you don't mind.

    4. FotisKoutoulakis commented on Dec 9, 2013

      FotisKoutoulakismannequin
      Mannequin

      I have finished the changes needed to move script_helper from Lib/test to Lib/test/support, and I have also documented it. Tests run gracefully (but be sure to check out if it works as intended on your machines too)

      Two notes though:

      1. I have only made the changes on the default branch. Will do 3.3 tomorrow.

      2. When it came to the documentation, I had to break the 80 characters limit, as going by it was resulting in weird rendering or wrong information depicted from sphinx (for example, when showing that script_helper functions belonged to test.support instead of the correct location, test.support.script_helper).

      Last but not least, this is one of my first contributions to Python, so I would appreciate your input.

    5. ncoghlan commented on Dec 9, 2013

      @ncoghlan
      ContributorAuthor

      I wouldn't worry about 3.3 at this point - the 3.3 test suite isn't going to see major changes for its final release, so the risk of merge conflicts is low.

    6. FotisKoutoulakis commented on Dec 9, 2013

      FotisKoutoulakismannequin
      Mannequin

      Hello again.

      Is everything ok with the patch? Is there something not working as expected? Perhaps an omission or something? Do I need to do something more to get it accepted?

      Thanks for your time.

    7. serhiy-storchaka commented on Dec 9, 2013

      @serhiy-storchaka
      Member

      Please left test.script_helper as alias to test.support.script_helper.

      I.e. test/script_helper.py should contains something like:

      from test.support.script_helper import *

      And test this with unmodifiable other tests.

    8. FotisKoutoulakis commented on Dec 9, 2013

      FotisKoutoulakismannequin
      Mannequin

      Ok, here is the second (modified patch) which contains a script so that no modifications are required to existing tests.

      I am uploading it as a second patch, so that the first one is left as a reference.

      As a sidenote, I fail to see convincing reasons for why we would want the second solution more than the first. The first one looks cleaner to my eyes. The only downside I can see to the original approach is breaking a couple of tests, which is something that can be fixed easily without even making it to the repo (running the tests in 2-3 could help find all possible broken tests beforehand).

      Could someone explain to me why the second solution is more desirable?

    9. serhiy-storchaka commented on Dec 9, 2013

      @serhiy-storchaka
      Member

      Third party code can use tests.script_helper.

      I prefer to do these changes in several steps:

      1. Move script_helper.py to Lib/test/support/, document it, and create an alias (with deprecation warning).
      2. Ensure that this doesn't break any buildbot.
      3. Change tests to use test.support.script_helper instead of test.script_helper.
      4. One or two versions later remove an alias.
    10. 5 remaining items

    11. ncoghlan commented on May 12, 2015

      @ncoghlan
      ContributorAuthor

      script_helper was moved to the test.support package in bpo-9517, so this issue is just about adding the docs now.

    12. changed the title [-]Rename and document test.script_helper as test.support.script_helper[/-] [+]Document test.support.script_helper[/+] on May 12, 2015
    13. ncoghlan commented on May 12, 2015

      @ncoghlan
      ContributorAuthor

      Also noting that my draft docs are over a year old now, so they need to be reviewed against the current state of the helper module.

    14. bobcatfish commented on May 18, 2015

      bobcatfishmannequin
      Mannequin

      I'm going to take a look at bringing these docs up to date and including the changes from bpo-24033.

    15. bobcatfish commented on Jun 6, 2015

      bobcatfishmannequin
      Mannequin

      @ncoghlan I've taken the test.rst changes from the previous diff and reviewed them against the latest script_helper (including updates from bpo-24033). Nothing had fallen behind, but I've added what was missing.

      • I've realized that spawn_python and the helper run_python I added in bpo-24033 are basically the same so I will reconcile those
      • Is there some way to load the docstrings from script_helper.py in test.rst instead of writing explanations for each method twice?
    16. vadmium commented on Jun 7, 2015

      @vadmium
      Member

      If you diffed your patch from a public revision in the main repository, there should be a nice “Review” link. Anyway, here are some comments on bpo-18576.patch:

      +.. function:: assert_python_ok(*args, **env_vars)
      +

      • Runs the interpreter with args and optional environment
      • variables, asserting that env_vars succeeds (rc == 0).

      Perhaps you mean *env_vars* are the optional environment variables, and that the interpreter is asserted to have succeeded.

      Also maybe clarify where the *__cleanenv* and *__isolated* keywords come from? Function signatures? Also applies to assert_python_failure(), run_python/_until_end().

      Maybe it is worth mentioning that assert_python_ok/failure() strip whitespace from the stderr stream. I seem to remember being tricked by this (writing a test to ensure stderr ended in a newline or something).

      • stdout are configured as binary pipes and stderr is merged with
      • stdout..

      There are two full stops above here..

      I encourage you to start sentences with capital letters (although I admit sometimes other people do not agree with this). Suggestions:

      + *kw* is passed through to subprocess.Popen as additional keyword
      + arguments.
      => The *kw* arguments are passed through to subprocess.Popen.

      + *source* is a Unicode string which will be written to the file as UTF-8.
      => The *source* argument is a Unicode string which will be written to the file as UTF-8.

      + *depth* controls how many deeply nested the package is.
      => The *depth* argument controls how deeply nested the package is.

      + Creates a new zip archive in the given directory, containing the specified
      + Python script/module

      Needs one of those full stops I mentioned earlier :)

    17. ncoghlan commented on Jun 7, 2015

      @ncoghlan
      ContributorAuthor

      As far as using docstrings for the online docs goes, there are some useful Sphinx add-ons that we've never enabled for the main Python docs (like autodoc, blockdiag, seqdiag) that could be good options to have available. For autodoc in particular, we prefer to avoid it for the main docs because "good docstring" and "good prose documentation" don't necessarily look alike. For ease of maintenance of test.support though, I think the "write a good docstring, get the online docs for free" rationale is a compelling one (since these docs are core contributor facing, rather than being aimed at Python users in general)

      docs@python.org would be the place to ask about the appropriateness of enabling some Sphinx add-ons. While enabling them seems like a reasonable idea to me, I don't personally know if there are actually technical issues with the idea, or if there just hasn't been a volunteer to add/enable them and update https://docs.python.org/devguide/documenting.html accordingly.

    18. bobcatfish commented on Jun 7, 2015

      bobcatfishmannequin
      Mannequin

      If you diffed your patch from a public revision in the main repository, there should be a nice “Review” link.

      Ah, thanks @vadmium!!! I've been confused about why some patches get review links and others do not >.<

      I'll have a new patch up shortly which is diffed against a public revision and has your suggested changes.

      For autodoc in particular, we prefer to avoid it for the main docs because "good docstring" and "good prose documentation" don't necessarily look alike.

      @ncoghlan for some reason I thought that the main docs were also auto generated from docstrings in the actual modules, but I can see now that that isn't the case.

      I'll reach out to docs@python.org to see how they feel about autogenerating the test.support docs.

    19. removed their assignment
      on Jun 28, 2015
    20. bobcatfish commented on Jun 28, 2015

      bobcatfishmannequin
      Mannequin

      Hey @vadmium!

      I've finally responded to your review feedback. I've attached a new patch, hopefully this time actually review-able. I've removed the docs for methods I added in @24033 so that this could be merged without it.

      Let me know if you have any more feedback, or if this could be merged.

      Thanks!

    21. vadmium commented on Jun 29, 2015

      @vadmium
      Member

      I left some more comments on Reitveld. The main one is I think stderr gets stripped with assert_python_ok(), but I don’t think stdout is touched. Correct me if I’m wrong though.

    22. mlouielu commented on Apr 22, 2017

      mlouielumannequin
      Mannequin

      The PR on GitHub is based on bobcatfist's patch, addressed on Martin request and some minor change.

    23. JulienPalard commented on Sep 9, 2019

      @JulienPalard
      Member

      All those functions has already been documented.

    24. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      docseasyteststype-feature

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions