Skip to content

Commit a8c6716

Browse files
Guide_Testing: add a note about get_test_file
1 parent ec058fb commit a8c6716

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

doc/guide/Guide_Testing.ipynb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,37 @@
169169
"Anything written to `stdout` by a test method is useful mainly for the developer of the test."
170170
]
171171
},
172+
{
173+
"cell_type": "markdown",
174+
"metadata": {},
175+
"source": [
176+
"### Test files\n",
177+
"\n",
178+
"For integration tests it can be required to read data from a file, in order to set up a test that aims to check functionality with non-trivial data, beyond the scope of unit tests.\n",
179+
"Some of thes test files can be found in the `climada/**/test/data` directories or in the `climada/data` directory. As mostly the case with large test data, it is not very well suitable for a Git repository.\n",
180+
"\n",
181+
"The preferable alternative is to post the data to the Climada Data-API with status `test_dataset` and retrieve the files on the fly from there during tests.\n",
182+
"To do this one can use the convenience method `climada.test.get_test_file`:"
183+
]
184+
},
185+
{
186+
"cell_type": "code",
187+
"execution_count": null,
188+
"metadata": {},
189+
"outputs": [],
190+
"source": [
191+
"from climada.test import get_test_file\n",
192+
"\n",
193+
"my_test_file = get_test_file(ds_name='my-test-file', file_format='hdf5') # returns a pathlib.Path object"
194+
]
195+
},
196+
{
197+
"cell_type": "markdown",
198+
"metadata": {},
199+
"source": [
200+
"Behind the scenes, `get_test_file` uses the `climada.util.api_client.Client` to identify the appropriate dataset and downloads the respective file to the local dataset cache (`~/climada/data/*`)."
201+
]
202+
},
172203
{
173204
"attachments": {},
174205
"cell_type": "markdown",

0 commit comments

Comments
 (0)