MCPcopy
hub / github.com/dask/dask / s3_base

Function s3_base

dask/bytes/tests/test_s3.py:82–116  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

80
81@pytest.fixture(scope="module")
82def s3_base():
83 with ensure_safe_environment_variables():
84 os.environ["AWS_ACCESS_KEY_ID"] = "foobar_key"
85 os.environ["AWS_SECRET_ACCESS_KEY"] = "foobar_secret"
86 # Ignore any local AWS credentials/config files as they can interfere with moto
87 os.environ["AWS_SHARED_CREDENTIALS_FILE"] = ""
88 os.environ["AWS_CONFIG_FILE"] = ""
89
90 # pipe to null to avoid logging in terminal
91 proc = subprocess.Popen(
92 shlex.split("moto_server s3 -p 5555"), stdout=subprocess.DEVNULL
93 )
94
95 timeout = time.perf_counter() + 8
96 while True:
97 try:
98 # OK to go once server is accepting connections
99 r = urllib.request.urlopen(endpoint_uri)
100 if r.status == 200:
101 break
102 except urllib.request.URLError:
103 pass
104 time.sleep(0.1)
105 assert time.perf_counter() < timeout, "Timed out waiting for moto server"
106 yield
107
108 # shut down external process
109 proc.terminate()
110 try:
111 proc.wait(timeout=3)
112 except subprocess.TimeoutExpired:
113 proc.kill()
114 if sys.platform == "win32":
115 # belt & braces
116 subprocess.call(f"TASKKILL /F /PID {proc.pid} /T")
117
118
119@pytest.fixture

Callers

nothing calls this directly

Calls 2

splitMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…