tests/seq.py
author pacien <pacien.trangirard@pacien.net>
Thu, 22 Sep 2022 16:09:53 +0200
changeset 49499 4f36738a869a
parent 49285 56f98406831b
permissions -rwxr-xr-x
tests: fix http-bad-server expected errors for python 3.10 (issue6643) The format of the error message changed with this version of Python. This also removes obsolete Python 3 checks.

#!/usr/bin/env python3
#
# A portable replacement for 'seq'
#
# Usage:
#   seq STOP              [1, STOP] stepping by 1
#   seq START STOP        [START, STOP] stepping by 1
#   seq START STEP STOP   [START, STOP] stepping by STEP

import os
import sys

try:
    import msvcrt

    msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
    msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
    msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
except ImportError:
    pass

start = 1
if len(sys.argv) > 2:
    start = int(sys.argv[1])

step = 1
if len(sys.argv) > 3:
    step = int(sys.argv[2])

stop = int(sys.argv[-1]) + 1

for i in range(start, stop, step):
    print(i)