Skip to content

Commit dbc5338

Browse files
committed
Test: tighten test-skip conditions and lengthen a subprocess sleep
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>
1 parent ebcb17b commit dbc5338

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

tests/aggregate_tests.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,34 @@
5353
# The format here is: if major is included, limit version to that listed here.
5454
# If minor is included, limit version to that listed here. Skip the test if any
5555
# such listed constraints don't match the python version currently running.
56+
# Note that this TUF implementation does not support any Python versions <2.7
57+
# or any Python3 versions <3.4.
5658
VERSION_SPECIFIC_TESTS = {
5759
'test_proxy_use': {'major': 2, 'minor': 7}} # Run test only if Python2.7
60+
# Further example:
61+
# 'test_abc': {'major': 2} # Run test only if Python2
62+
63+
# Test consistency of VERSION_SPECIFIC_TESTS
64+
for t in VERSION_SPECIFIC_TESTS:
65+
if 'minor' in VERSION_SPECIFIC_TESTS[t]:
66+
assert 'major' in VERSION_SPECIFIC_TESTS[t], 'Illogical test constraint'
67+
for keyword in VERSION_SPECIFIC_TESTS[t]:
68+
assert keyword in ['major', 'minor'], 'Unrecognized test constraint'
69+
5870

5971
# Remove '.py' from each filename to allow loadTestsFromNames() (called below)
6072
# to properly load the file as a module.
6173
tests_without_extension = []
6274
for test in tests_list:
75+
assert test[-3:] == '.py', 'aggregate_tests.py is inconsistent; fix.'
6376
test = test[:-3]
6477
if test in VERSION_SPECIFIC_TESTS:
6578
if 'major' in VERSION_SPECIFIC_TESTS[test] \
6679
and sys.version_info.major != VERSION_SPECIFIC_TESTS[test]['major']:
6780
continue
68-
elif 'minor' in VERSION_SPECIFIC_TESTS[test] \
69-
and sys.version_info.minor != VERSION_SPECIFIC_TESTS[test]['minor']:
70-
continue
81+
if 'minor' in VERSION_SPECIFIC_TESTS[test] \
82+
and sys.version_info.minor != VERSION_SPECIFIC_TESTS[test]['minor']:
83+
continue
7184
tests_without_extension.append(test)
7285

7386
# Randomize the order in which the tests run. Randomization might catch errors

tests/test_proxy_use.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ def setUpClass(cls):
123123
# start listening before allowing tests to begin, lest we get "Connection
124124
# refused" errors. On the first test system. 0.1s was too short and 0.15s
125125
# was long enough. Use 0.5s to be safe, and if issues arise, increase it.
126-
time.sleep(0.5)
126+
# Observed some occasional AppVeyor failures, so increasing this to 1s.
127+
time.sleep(1)
127128

128129

129130

0 commit comments

Comments
 (0)