radiocosmology / alpenhorn

Alpenhorn is a service for managing an archive of scientific data.
MIT License
2 stars 1 forks source link

fix(tests): Fix test-suite for Click changes in Python 3.9 #139

Closed ketiltrout closed 2 years ago

ketiltrout commented 2 years ago

I think all of these failures are due to the test suite relying on particular behaviour exhibited by Click that is not part of Click's public API and that has changed between versions.

Tests which depends on the text flow of usage output (--help) are inherently fragile because they assume Click's text reflowing isn't going to change.

Similarly tests which look for Click-produced error messages ("Invalid value for [...]") also aren't a good idea.

The rest of these tests were dependent on the click.progressbar call in client.node.verify not printing the supplied "Scanning files" label, which it might not do if the elapsed time is small enough, but is also something that can't be relied on. (This is worked around by replacing re.match calls with re.search to not tie the search pattern to the start of the string.)

Also fix a typo in alpenhorn/client/transport.py

ketiltrout commented 2 years ago

I leave to your judgement, but do we need the ===Summary=== if the return exit code is 0?

Maybe. I didn't think about the tests too deeply, but it might be that we're checking the result of the verify operation (i.e. how many files are good/corrupt/missing?) Checking these texts shouldn't be problematic to test, since they're output that our code produces (rather than Click).