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

Option to not-exit on test #47629

Closed
pupeno mannequin opened this issue Jul 16, 2008 · 17 comments
Closed

Option to not-exit on test #47629

pupeno mannequin opened this issue Jul 16, 2008 · 17 comments
Assignees
Labels
stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-feature A feature request or enhancement

Comments

@pupeno
Copy link
Mannequin

pupeno mannequin commented Jul 16, 2008

BPO 3379
Nosy @warsaw, @birkenfeld, @benjaminp, @voidspace
Files
  • add_avoid_exit_option.diff: Patch to add sption to not-exit on test
  • add_avoid_exit_option.diff: Patch to add sption to not-exit on test, including documentation
  • add_avoid_exit_option.diff: Patch to add sption to not-exit on test, including documentation and tests
  • unittest-no-exit.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/warsaw'
    closed_at = <Date 2009-05-02.12:15:35.200>
    created_at = <Date 2008-07-16.15:13:21.191>
    labels = ['tests', 'type-feature', 'library']
    title = 'Option to not-exit on test'
    updated_at = <Date 2009-05-02.12:16:25.772>
    user = 'https://bugs.python.org/pupeno'

    bugs.python.org fields:

    activity = <Date 2009-05-02.12:16:25.772>
    actor = 'michael.foord'
    assignee = 'barry'
    closed = True
    closed_date = <Date 2009-05-02.12:15:35.200>
    closer = 'michael.foord'
    components = ['Library (Lib)', 'Tests']
    creation = <Date 2008-07-16.15:13:21.191>
    creator = 'pupeno'
    dependencies = []
    files = ['10908', '10909', '10929', '13790']
    hgrepos = []
    issue_num = 3379
    keywords = ['patch']
    message_count = 17.0
    messages = ['69791', '69792', '69808', '69809', '69896', '69991', '69994', '70032', '70038', '70172', '85726', '86565', '86566', '86605', '86606', '86940', '86941']
    nosy_count = 5.0
    nosy_names = ['barry', 'georg.brandl', 'pupeno', 'benjamin.peterson', 'michael.foord']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue3379'
    versions = ['Python 3.1', 'Python 2.7']

    @pupeno
    Copy link
    Mannequin Author

    pupeno mannequin commented Jul 16, 2008

    Added an option, called exit, that when set to false, will make the
    tests not exit at the end. This is useful when you are doing Lisp-like
    development having a REPL (interpreter/prompt) opened in Emacs and
    running the tests over and over on it.
    Currently, the tests will exit the interpreter, causing the in-Emacs
    interpreter to close as well.
    It is by default set to false, so the default behavior is still the
    same. When set to true the default behavior shouldn't change much
    because at the end of the tests you are going to exit anyway. The only
    difference is that no exit code will be provided. There's actually
    something else, because the Python test suite hangs in a test case when
    this is set to true, but this should be of no concern, as default is false.

    @pupeno pupeno mannequin added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Jul 16, 2008
    @benjaminp
    Copy link
    Contributor

    This is related to (maybe a duplicate of) bpo-2674.

    @pupeno
    Copy link
    Mannequin Author

    pupeno mannequin commented Jul 16, 2008

    Indeed this patch can be considered a fix for bpo-2674, but, it should be
    documented appropriately. Should that be in
    http://docs.python.org/dev/3.0/library/unittest.html ?

    @pupeno
    Copy link
    Mannequin Author

    pupeno mannequin commented Jul 16, 2008

    Added some documentation.

    @pupeno
    Copy link
    Mannequin Author

    pupeno mannequin commented Jul 17, 2008

    Added tests.

    @birkenfeld
    Copy link
    Member

    Barry, this looks useful and shouldn't be at all disruptive even after
    beta2. May I check it in?

    @warsaw
    Copy link
    Member

    warsaw commented Jul 18, 2008

    I'm not sure it's a good idea. When exit=False, don't you lose the
    results? It would be better to return the results, but then that makes
    for an ugly API (changing the return value based on an argument is a
    general no-no in Python).

    It would seem better to add a new method that returned the results
    instead of exiting. You'd probably want to refactor runTests().

    @birkenfeld
    Copy link
    Member

    Well, the results are displayed on stdout like they are if sys.exit is
    used. As the first post explains, the use-case is running the tests from
    an interactive interpreter.

    @warsaw
    Copy link
    Member

    warsaw commented Jul 19, 2008

    I still think a different method would be better for the no-exit
    functionality.

    @pupeno
    Copy link
    Mannequin Author

    pupeno mannequin commented Jul 23, 2008

    What about always returning the results. Granted, when sys.exit is run
    there will be no results returned, but then nothing to get the results.
    If we divided in two functions, would one be unittest.main and the other
    unittest.nonExitingMain? Sounds ugly, but OK if no other better way is
    possible.

    I personally believe that main should not hijack the current interpreter
    with sys.exit at all, but I understand that behavior is not changeable
    at the moment (is it?).

    @devdanzin devdanzin mannequin added the tests Tests in the Lib/test dir label Apr 7, 2009
    @voidspace
    Copy link
    Contributor

    Not returning the results is not a problem - if you needed access to the
    results you would hardly be using this API in the first place.

    The obvious use case if for running tests from an interactive
    environment where you are using the visual output on stdout.

    If you want to collect the results you do it programmatically.

    I wouldn't be opposed to main() returning the results though, but think
    we should apply the patch rather than debate further. To action!

    @voidspace
    Copy link
    Contributor

    Patch that adds the same exit functionality, but also stores the result
    as an instance attribute on the return TestProgram instance.

    As this functionality has been requested several times my intention is
    to apply this patch.

    @benjaminp
    Copy link
    Contributor

    Michael, this patch seems to include extra addCleanup() stuff.

    @voidspace
    Copy link
    Contributor

    Damn somehow managed to upload the patch to the wrong issue twice in a
    row. Must have been late at night.

    @voidspace
    Copy link
    Contributor

    Correct patch this time. If there are no objections I'll apply this in a
    couple of days.

    @voidspace
    Copy link
    Contributor

    Committed in revision 71291.

    @voidspace
    Copy link
    Contributor

    No, make that revision 72191. :-)

    @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
    stdlib Python modules in the Lib dir 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