diff --git a/xarray/tests/test_backends.py b/xarray/tests/test_backends.py index bad9e99c042..1888f0767be 100644 --- a/xarray/tests/test_backends.py +++ b/xarray/tests/test_backends.py @@ -3356,3 +3356,14 @@ def test_no_warning_from_dask_effective_get(): ds = Dataset() ds.to_netcdf(tmpfile) assert len(record) == 0 + + +@requires_scipy_or_netCDF4 +def test_source_encoding_always_present(): + # Test for GH issue #2550. + rnddata = np.random.randn(10) + original = Dataset({'foo': ('x', rnddata)}) + with create_tmp_file() as tmp: + original.to_netcdf(tmp) + with open_dataset(tmp) as ds: + assert ds.encoding['source'] == tmp