| 173 | assert isinstance(client.timeout, httpx.Timeout) |
| 174 | |
| 175 | def test_copy_default_headers(self) -> None: |
| 176 | client = OpenAI( |
| 177 | base_url=base_url, |
| 178 | api_key=api_key, |
| 179 | admin_api_key=admin_api_key, |
| 180 | _strict_response_validation=True, |
| 181 | default_headers={"X-Foo": "bar"}, |
| 182 | ) |
| 183 | assert client.default_headers["X-Foo"] == "bar" |
| 184 | |
| 185 | # does not override the already given value when not specified |
| 186 | copied = client.copy() |
| 187 | assert copied.default_headers["X-Foo"] == "bar" |
| 188 | |
| 189 | # merges already given headers |
| 190 | copied = client.copy(default_headers={"X-Bar": "stainless"}) |
| 191 | assert copied.default_headers["X-Foo"] == "bar" |
| 192 | assert copied.default_headers["X-Bar"] == "stainless" |
| 193 | |
| 194 | # uses new values for any already given headers |
| 195 | copied = client.copy(default_headers={"X-Foo": "stainless"}) |
| 196 | assert copied.default_headers["X-Foo"] == "stainless" |
| 197 | |
| 198 | # set_default_headers |
| 199 | |
| 200 | # completely overrides already set values |
| 201 | copied = client.copy(set_default_headers={}) |
| 202 | assert copied.default_headers.get("X-Foo") is None |
| 203 | |
| 204 | copied = client.copy(set_default_headers={"X-Bar": "Robert"}) |
| 205 | assert copied.default_headers["X-Bar"] == "Robert" |
| 206 | |
| 207 | with pytest.raises( |
| 208 | ValueError, |
| 209 | match="`default_headers` and `set_default_headers` arguments are mutually exclusive", |
| 210 | ): |
| 211 | client.copy(set_default_headers={}, default_headers={"X-Foo": "Bar"}) |
| 212 | client.close() |
| 213 | |
| 214 | def test_copy_default_query(self) -> None: |
| 215 | client = OpenAI( |