mypy: Use python3 type syntax in test-backend.

This commit is contained in:
Raymond Akornor 2019-03-15 14:37:42 +00:00 committed by Tim Abbott
parent 193de819b8
commit ea112828dc
1 changed files with 4 additions and 8 deletions

View File

@ -145,8 +145,7 @@ enforce_fully_covered = sorted(target_fully_covered - not_yet_fully_covered)
FAILED_TEST_PATH = 'var/last_test_failure.json' FAILED_TEST_PATH = 'var/last_test_failure.json'
def get_failed_tests(): def get_failed_tests() -> List[str]:
# type: () -> List[str]
try: try:
with open(FAILED_TEST_PATH, 'r') as f: with open(FAILED_TEST_PATH, 'r') as f:
return ujson.load(f) return ujson.load(f)
@ -154,14 +153,12 @@ def get_failed_tests():
print("var/last_test_failure.json doesn't exist; running all tests.") print("var/last_test_failure.json doesn't exist; running all tests.")
return [] return []
def write_failed_tests(failed_tests): def write_failed_tests(failed_tests: List[str]) -> None:
# type: (List[str]) -> None
if failed_tests: if failed_tests:
with open(FAILED_TEST_PATH, 'w') as f: with open(FAILED_TEST_PATH, 'w') as f:
ujson.dump(failed_tests, f) ujson.dump(failed_tests, f)
def block_internet(): def block_internet() -> None:
# type: () -> None
# We are blocking internet currently by assuming mostly any test would use # We are blocking internet currently by assuming mostly any test would use
# httplib2 to access internet. # httplib2 to access internet.
requests_orig = requests.request requests_orig = requests.request
@ -300,8 +297,7 @@ def main() -> None:
for i, suite in enumerate(args): for i, suite in enumerate(args):
args[i] = suite.rstrip('/').replace("/", ".") args[i] = suite.rstrip('/').replace("/", ".")
def rewrite_arguments(search_key): def rewrite_arguments(search_key: str) -> None:
# type: (str) -> None
for root, dirs, files_names in os.walk(zerver_test_dir, topdown=False): for root, dirs, files_names in os.walk(zerver_test_dir, topdown=False):
for file_name in files_names: for file_name in files_names:
# Check for files starting with alphanumeric characters and ending with '.py' # Check for files starting with alphanumeric characters and ending with '.py'