satpy.tests.test_readers module

Test classes and functions in the readers/__init__.py module.

class satpy.tests.test_readers.TestDatasetDict(methodName='runTest')[source]

Bases: TestCase

Test DatasetDict and its methods.

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

_classSetupFailed = False
_class_cleanups = []
setUp()[source]

Create a test DatasetDict.

test_contains()[source]

Test DatasetDict contains method.

test_get_key()[source]

Test ‘get_key’ special functions.

test_getitem()[source]

Test DatasetDict getitem with different arguments.

test_init_dict()[source]

Test DatasetDict init with a regular dict argument.

test_init_noargs()[source]

Test DatasetDict init with no arguments.

test_keys()[source]

Test keys method of DatasetDict.

test_setitem()[source]

Test setitem method of DatasetDict.

class satpy.tests.test_readers.TestFSFile[source]

Bases: object

Test the FSFile class.

test_equality(local_filename, local_filename2, local_zip_file)[source]

Test that FSFile compares equal when it should.

test_fsfile_with_fs_open_file_abides_pathlike(local_file, random_string)[source]

Test that FSFile abides PathLike for fsspec OpenFile instances.

test_fsfile_with_pathlike(local_filename)[source]

Test FSFile with path-like object.

test_fsfile_with_regular_filename_abides_pathlike(random_string)[source]

Test that FSFile abides PathLike for regular filenames.

test_fsfile_with_regular_filename_and_fs_spec_abides_pathlike(random_string)[source]

Test that FSFile abides PathLike for filename+fs instances.

test_hash(local_filename, local_filename2, local_zip_file)[source]

Test that FSFile hashing behaves sanely.

test_open_local_fs_file(local_file)[source]

Test opening a localfs file.

test_open_regular_file(local_filename)[source]

Test opening a regular file.

test_open_zip_fs_openfile(local_filename2, local_zip_file)[source]

Test opening a zipfs openfile.

test_open_zip_fs_regular_filename(local_filename2, local_zip_file)[source]

Test opening a zipfs with a regular filename provided.

test_regular_filename_is_returned_with_str(random_string)[source]

Test that str give the filename.

test_repr_includes_filename(local_file, random_string)[source]

Test that repr includes the filename.

test_sorting_fsfiles(local_filename, local_filename2, local_zip_file)[source]

Test sorting FSFiles.

class satpy.tests.test_readers.TestFindFilesAndReaders[source]

Bases: object

Test the find_files_and_readers utility function.

setup_method()[source]

Wrap HDF5 file handler with our own fake handler.

teardown_method()[source]

Stop wrapping the HDF5 file handler.

test_bad_sensor()[source]

Test bad sensor doesn’t find any files.

test_no_parameters(viirs_file)[source]

Test with no limiting parameters.

test_no_parameters_both_atms_and_viirs(viirs_file, atms_file)[source]

Test with no limiting parameters when there area both atms and viirs files in the same directory.

test_old_reader_name_mapping()[source]

Test that requesting old reader names raises a warning.

test_pending_old_reader_name_mapping()[source]

Test that requesting pending old reader names raises a warning.

test_reader_load_failed()[source]

Test that an exception is raised when a reader can’t be loaded.

test_reader_name(viirs_file)[source]

Test with default base_dir and reader specified.

test_reader_name_matched_end_time(viirs_file)[source]

Test with end matching the filename.

End time in the middle of the file time should still match the file.

test_reader_name_matched_start_end_time(viirs_file)[source]

Test with start and end time matching the filename.

test_reader_name_matched_start_time(viirs_file)[source]

Test with start matching the filename.

Start time in the middle of the file time should still match the file.

test_reader_name_unmatched_start_end_time(viirs_file)[source]

Test with start and end time matching the filename.

test_reader_other_name(monkeypatch, tmp_path)[source]

Test with default base_dir and reader specified.

test_sensor(viirs_file)[source]

Test that readers for the current sensor are loaded.

test_sensor_no_files()[source]

Test that readers for the current sensor are loaded.

class satpy.tests.test_readers.TestGroupFiles(methodName='runTest')[source]

Bases: TestCase

Test the ‘group_files’ utility function.

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

_classSetupFailed = False
_class_cleanups = []
_filenames_abi_glm = ['OR_ABI-L1b-RadF-M6C14_G16_s19000010000000_e19000010005000_c20403662359590.nc', 'OR_ABI-L1b-RadF-M6C14_G16_s19000010010000_e19000010015000_c20403662359590.nc', 'OR_ABI-L1b-RadF-M6C14_G16_s19000010020000_e19000010025000_c20403662359590.nc', 'OR_GLM-L2-GLMF-M3_G16_s19000010000000_e19000010001000_c20403662359590.nc', 'OR_GLM-L2-GLMF-M3_G16_s19000010001000_e19000010002000_c20403662359590.nc', 'OR_GLM-L2-GLMF-M3_G16_s19000010002000_e19000010003000_c20403662359590.nc', 'OR_GLM-L2-GLMF-M3_G16_s19000010003000_e19000010004000_c20403662359590.nc', 'OR_GLM-L2-GLMF-M3_G16_s19000010004000_e19000010005000_c20403662359590.nc', 'OR_GLM-L2-GLMF-M3_G16_s19000010005000_e19000010006000_c20403662359590.nc', 'OR_GLM-L2-GLMF-M3_G16_s19000010006000_e19000010007000_c20403662359590.nc', 'OR_GLM-L2-GLMF-M3_G16_s19000010007000_e19000010008000_c20403662359590.nc', 'OR_GLM-L2-GLMF-M3_G16_s19000010008000_e19000010009000_c20403662359590.nc', 'OR_GLM-L2-GLMF-M3_G16_s19000010009000_e19000010010000_c20403662359590.nc', 'OR_GLM-L2-GLMF-M3_G16_s19000010010000_e19000010011000_c20403662359590.nc', 'OR_GLM-L2-GLMF-M3_G16_s19000010011000_e19000010012000_c20403662359590.nc', 'OR_GLM-L2-GLMF-M3_G16_s19000010012000_e19000010013000_c20403662359590.nc', 'OR_GLM-L2-GLMF-M3_G16_s19000010013000_e19000010014000_c20403662359590.nc', 'OR_GLM-L2-GLMF-M3_G16_s19000010014000_e19000010015000_c20403662359590.nc', 'OR_GLM-L2-GLMF-M3_G16_s19000010015000_e19000010016000_c20403662359590.nc']
setUp()[source]

Set up test filenames to use.

test_bad_reader()[source]

Test that reader not existing causes an error.

test_default_behavior()[source]

Test the default behavior with the ‘abi_l1b’ reader.

test_default_behavior_set()[source]

Test the default behavior with the ‘abi_l1b’ reader.

test_large_time_threshold()[source]

Test what happens when the time threshold holds multiple files.

test_multi_readers()[source]

Test passing multiple readers.

test_multi_readers_empty_groups_missing_skip()[source]

Verify empty groups are skipped.

Verify that all groups lacking ABI are skipped, resulting in only three groups that are all non-empty for both instruments.

test_multi_readers_empty_groups_passed()[source]

Verify that all groups are there, resulting in some that are empty.

test_multi_readers_empty_groups_raises_filenotfounderror()[source]

Test behaviour on empty groups passing multiple readers.

Make sure it raises an exception, for there will be groups containing GLM but not ABI.

test_multi_readers_invalid_parameter()[source]

Verify that invalid missing parameter raises ValueError.

test_no_reader()[source]

Test that reader does not need to be provided.

test_non_datetime_group_key()[source]

Test what happens when the start_time isn’t used for grouping.

test_two_instruments_files()[source]

Test the behavior when two instruments files are provided.

This is undesired from a user point of view since we don’t want G16 and G17 files in the same Scene. Readers (like abi_l1b) are or can be configured to have specific group keys for handling these situations. Due to that this test forces the fallback group keys of (‘start_time’,).

test_two_instruments_files_split()[source]

Test the default behavior when two instruments files are provided and split.

Tell the sorting to include the platform identifier as another field to use for grouping.

test_unknown_files()[source]

Test that error is raised on unknown files.

test_viirs_orbits()[source]

Test a reader that doesn’t use ‘start_time’ for default grouping.

test_viirs_override_keys()[source]

Test overriding a group keys to add ‘start_time’.

class satpy.tests.test_readers.TestReaderLoader(methodName='runTest')[source]

Bases: TestCase

Test the load_readers function.

Assumes that the VIIRS SDR reader exists and works.

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

_classSetupFailed = False
_class_cleanups = []
setUp()[source]

Wrap HDF5 file handler with our own fake handler.

tearDown()[source]

Stop wrapping the HDF5 file handler.

test_all_filtered()[source]

Test behaviour if no file matches the filter parameters.

test_all_filtered_multiple()[source]

Test behaviour if no file matches the filter parameters.

test_almost_all_filtered()[source]

Test behaviour if only one reader has datasets.

test_bad_reader_name_with_filenames()[source]

Test bad reader name with filenames provided.

test_empty_filenames_as_dict()[source]

Test passing filenames as a dictionary with an empty list of filenames.

test_filenames_and_reader()[source]

Test with filenames and reader specified.

test_filenames_as_dict()[source]

Test loading readers where filenames are organized by reader.

test_filenames_as_dict_bad_reader()[source]

Test loading with filenames dict but one of the readers is bad.

test_filenames_as_dict_with_reader()[source]

Test loading from a filenames dict with a single reader specified.

This can happen in the deprecated Scene behavior of passing a reader and a base_dir.

test_filenames_as_path()[source]

Test with filenames specified as pathlib.Path.

test_filenames_only()[source]

Test with filenames specified.

test_missing_requirements(*mocks)[source]

Test warnings and exceptions in case of missing requirements.

test_no_args()[source]

Test no args provided.

This should check the local directory which should have no files.

class satpy.tests.test_readers.TestYAMLFiles[source]

Bases: object

Test and analyze the reader configuration files.

test_available_readers()[source]

Test the ‘available_readers’ function.

test_available_readers_base_loader(monkeypatch)[source]

Test the ‘available_readers’ function for yaml loader type BaseLoader.

test_filename_matches_reader_name()[source]

Test that every reader filename matches the name in the YAML.

satpy.tests.test_readers._assert_is_open_file_and_close(opened)[source]
satpy.tests.test_readers._generate_random_string()[source]
satpy.tests.test_readers._local_file(tmp_path_factory, filename: str) Iterator[Path][source]
satpy.tests.test_readers._open_h5py()[source]
satpy.tests.test_readers._open_xarray_default()[source]
satpy.tests.test_readers._open_xarray_h5netcdf()[source]
satpy.tests.test_readers._open_xarray_netcdf4()[source]
satpy.tests.test_readers._posixify_path(filename)[source]
satpy.tests.test_readers.atms_file(tmp_path, monkeypatch)[source]

Create a dummy atms file.

satpy.tests.test_readers.local_file(local_filename)[source]

Open local file with fsspec.

satpy.tests.test_readers.local_filename(tmp_path_factory, random_string)[source]

Create simple on-disk file.

satpy.tests.test_readers.local_filename2(tmp_path_factory)[source]

Create a second local file.

satpy.tests.test_readers.local_hdf5_filename(tmp_path_factory)[source]

Create on-disk HDF5 file.

satpy.tests.test_readers.local_hdf5_fsspec(local_hdf5_filename)[source]

Get fsspec OpenFile pointing to local HDF5 file.

satpy.tests.test_readers.local_hdf5_path(local_hdf5_filename)[source]

Get Path object pointing to local HDF5 file.

satpy.tests.test_readers.local_netcdf_filename(tmp_path_factory)[source]

Create a simple local NetCDF file.

satpy.tests.test_readers.local_netcdf_fsfile(local_netcdf_fsspec)[source]

Get FSFile object wrapping an fsspec OpenFile pointing to local netcdf file.

satpy.tests.test_readers.local_netcdf_fsspec(local_netcdf_filename)[source]

Get fsspec OpenFile object pointing to local netcdf file.

satpy.tests.test_readers.local_netcdf_path(local_netcdf_filename)[source]

Get Path object pointing to local netcdf file.

satpy.tests.test_readers.local_zip_file(local_filename2)[source]

Create local zip file containing one local file.

satpy.tests.test_readers.make_dataid(**items)[source]

Make a data id.

satpy.tests.test_readers.random_string()[source]

Random string to be used as fake file content.

satpy.tests.test_readers.test_open_file_or_filename(file_thing, create_read_func)[source]

Test various combinations of file-like things and opening them with various libraries.

satpy.tests.test_readers.viirs_file(tmp_path, monkeypatch)[source]

Create a dummy viirs file.