Skip to content

Commit

Permalink
Test: tighten test-skip conditions and lengthen a subprocess sleep
Browse files Browse the repository at this point in the history
After seeing some AppVeyor failures, I've increased the wait after
starting test HTTP, HTTPS, and proxy servers from 0.5s to 1s, to make
it less likely that tests will fail because the servers weren't done
starting up yet.

After some review comments by @aaaaalbert, I've tightened the logic
in aggregate_tests.py around which tests to skip unless a certain
Python version is running, and added some consistency checks.

Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
  • Loading branch information
awwad committed Oct 2, 2018
1 parent ebcb17b commit dbc5338
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
19 changes: 16 additions & 3 deletions tests/aggregate_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,34 @@
# The format here is: if major is included, limit version to that listed here.
# If minor is included, limit version to that listed here. Skip the test if any
# such listed constraints don't match the python version currently running.
# Note that this TUF implementation does not support any Python versions <2.7
# or any Python3 versions <3.4.
VERSION_SPECIFIC_TESTS = {
'test_proxy_use': {'major': 2, 'minor': 7}} # Run test only if Python2.7
# Further example:
# 'test_abc': {'major': 2} # Run test only if Python2

# Test consistency of VERSION_SPECIFIC_TESTS
for t in VERSION_SPECIFIC_TESTS:
if 'minor' in VERSION_SPECIFIC_TESTS[t]:
assert 'major' in VERSION_SPECIFIC_TESTS[t], 'Illogical test constraint'
for keyword in VERSION_SPECIFIC_TESTS[t]:
assert keyword in ['major', 'minor'], 'Unrecognized test constraint'


# Remove '.py' from each filename to allow loadTestsFromNames() (called below)
# to properly load the file as a module.
tests_without_extension = []
for test in tests_list:
assert test[-3:] == '.py', 'aggregate_tests.py is inconsistent; fix.'
test = test[:-3]
if test in VERSION_SPECIFIC_TESTS:
if 'major' in VERSION_SPECIFIC_TESTS[test] \
and sys.version_info.major != VERSION_SPECIFIC_TESTS[test]['major']:
continue
elif 'minor' in VERSION_SPECIFIC_TESTS[test] \
and sys.version_info.minor != VERSION_SPECIFIC_TESTS[test]['minor']:
continue
if 'minor' in VERSION_SPECIFIC_TESTS[test] \
and sys.version_info.minor != VERSION_SPECIFIC_TESTS[test]['minor']:
continue
tests_without_extension.append(test)

# Randomize the order in which the tests run. Randomization might catch errors
Expand Down
3 changes: 2 additions & 1 deletion tests/test_proxy_use.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ def setUpClass(cls):
# start listening before allowing tests to begin, lest we get "Connection
# refused" errors. On the first test system. 0.1s was too short and 0.15s
# was long enough. Use 0.5s to be safe, and if issues arise, increase it.
time.sleep(0.5)
# Observed some occasional AppVeyor failures, so increasing this to 1s.
time.sleep(1)



Expand Down

0 comments on commit dbc5338

Please sign in to comment.