Changeset 60ed7d1 in mod_gnutls


Ignore:
Timestamp:
Jan 9, 2020, 11:43:02 AM (11 months ago)
Author:
Fiona Klute <fiona.klute@…>
Branches:
master, proxy-ticket
Children:
ff039b1
Parents:
7e10018
Message:

Allow the prepare_env hook to return a cleanup callback

Location:
test
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • test/mgstest/hooks.py

    r7e10018 r60ed7d1  
    3030        2. Set any additional environment variables the test might
    3131        need.
     32
     33        If the hook creates any resources that need to be cleaned up
     34        after the test (e.g. delete a temporary file), it should
     35        return a callable which performs the cleanup. That callable
     36        will be called without arguments when the test services are
     37        stopped.
    3238
    3339    run_connection:
  • test/runtest.py

    r7e10018 r60ed7d1  
    136136
    137137    # This hook may modify the environment as needed for the test.
     138    cleanup_callback = None
    138139    try:
    139140        if plugin.prepare_env:
    140             plugin.prepare_env()
     141            cleanup_callback = plugin.prepare_env()
    141142    except SkipTest as skip:
    142143        print(f'Skipping: {skip!s}')
     
    148149
    149150    with contextlib.ExitStack() as service_stack:
     151        if cleanup_callback:
     152            service_stack.callback(cleanup_callback)
    150153        service_stack.enter_context(lockfile('test.lock', nolock='MGS_NETNS_ACTIVE' in os.environ))
    151154        service_stack.enter_context(ocsp.run())
Note: See TracChangeset for help on using the changeset viewer.