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

test: stop using unittest_toolbox in new tests #1792

Merged
merged 2 commits into from
Jan 25, 2022

Commits on Jan 24, 2022

  1. test: define TESTS_DIR constant

    Define TESTS_DIR constant in tests/util.py as full path to the
    parent directory of the util module. This may be used to reliably
    read other files in tests dir, such es "repository_data" or
    "simple_server", regardless of cwd.
    
    This commit also replaces a couple of `getcwd() + "filename"` with
    `TESTS_DIR + filename`, so that in the future (post theupdateframework#1790) we
    should be able to invoke the tests from anywhere, not only from
    within the tests directory as is now the case.
    
    Signed-off-by: Lukas Puehringer <[email protected]>
    lukpueh committed Jan 24, 2022
    Configuration menu
    Copy the full SHA
    7da6a38 View commit details
    Browse the repository at this point in the history
  2. test: stop using unittest_toolbox in new tests

    Update new test modules to stop using unittest_toolbox, in
    preparation for its removal in theupdateframework#1790.
    
    The tools provided by unittest_toolbox can easily (in a more
    obvious way) be replaced by using the standard library modules
    `tempfile` and `random` (no more used) directly.
    
    In the case of tempdir and -file creation/removal, skipping the use
    of unittest_toolbox, which does this by default, also uncovers some
    test cleanup failures, which would occur when temporary test
    directories were removed while a test server hadn't released them.
    (see `except OSError: pass` in unittest_toolbox's `tearDown`
    method)
    
    **Change details**
    
    **test_fetcher_ng.py:**
    - Stop implicitly creating (setUp) and removing (tearDown) tmp test
    dirs.  -Move now manual creation of an exemplary targets file to
    setUpClass, as the same file is used by all tests. And remove it
    explicitly in tearDownClass after killing the server (see note
    about failure above).  - Trigger URL parsing error with a hardcoded
    invalid URL string instead of a random string.
    
    **test_updater_ng.py**
    - Stop implicitly creating (setUp) and removing (tearDown) tmp test
    dirs.
    - Explicitly create tmp test dirs in setUp, but don't remove
    them in tearDown to avoid above mentioned failures. They will be
    removed all at once when removing the tmp root test dir in
    tearDownClass
    
    Signed-off-by: Lukas Puehringer <[email protected]>
    lukpueh committed Jan 24, 2022
    Configuration menu
    Copy the full SHA
    3ed21ab View commit details
    Browse the repository at this point in the history