Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sivel
GitHub Repository: sivel/speedtest-cli
Path: blob/master/tests/scripts/source.py
280 views
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
# Copyright 2018 Matt Martz
4
# All Rights Reserved.
5
#
6
# Licensed under the Apache License, Version 2.0 (the "License"); you may
7
# not use this file except in compliance with the License. You may obtain
8
# a copy of the License at
9
#
10
# http://www.apache.org/licenses/LICENSE-2.0
11
#
12
# Unless required by applicable law or agreed to in writing, software
13
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
# License for the specific language governing permissions and limitations
16
# under the License.
17
18
import sys
19
import subprocess
20
21
cmd = [sys.executable, 'speedtest.py', '--source', '127.0.0.1']
22
23
p = subprocess.Popen(
24
cmd,
25
stdout=subprocess.PIPE,
26
stderr=subprocess.PIPE
27
)
28
29
stdout, stderr = p.communicate()
30
31
if p.returncode != 1:
32
raise SystemExit('%s did not fail with exit code 1' % ' '.join(cmd))
33
34
if 'Invalid argument'.encode() not in stderr:
35
raise SystemExit(
36
'"Invalid argument" not found in stderr:\n%s' % stderr.decode()
37
)
38
39