def test_nodoc(method): with pytest.raises(ValueError) as excinfo: getattr(xcdo.CDO(ds), method)(231).result() assert method + ' not supported' in str(excinfo.value)
def test_wrong_input(): with pytest.raises(AssertionError) as excinfo: xcdo.CDO(filename) assert 'Input not a xr.Dataset' in str(excinfo.value)
def test_wrong_method(method): with pytest.raises(ValueError) as excinfo: getattr(xcdo.CDO(ds), method)(231).result() assert method + ' is not a cdo method' in str(excinfo.value)
def test_forbidden_args(method): with pytest.raises(ValueError) as excinfo: getattr(xcdo.CDO(ds), method)(231).result() assert method + ' does not take any arguments' in str(excinfo.value)
def test_default_options_given(): data = xcdo.CDO(ds).mermean().result() options = data.attrs['history'].split('cdo', 1)[1].split('mermean', 1)[0] assert ' -O -f nc ' == options
def test_mandatory_args(method): with pytest.raises(ValueError) as excinfo: getattr(xcdo.CDO(ds), method)().zonmean().result() assert 'Arguments are mandatory for' in str(excinfo.value)
def test_unlimited_args(method): with pytest.raises(TypeError) as excinfo: getattr(xcdo.CDO(ds), method)().zonmean().result() assert 'because of unlimited input of method' in str(excinfo.value)
def test_no_input_after_noncinput(): with pytest.raises(TypeError) as excinfo: xcdo.CDO(ds).sinfon().zonmean().result() assert 'does not allow further chaining, because of' in str(excinfo.value)
def test_no_value(): with pytest.raises(ValueError) as excinfo: xcdo.CDO(ds).zonmean(23).result() assert 'does not take any arguments' in str(excinfo.value)
def test_back_to_back_execution(): xcdo.CDO(ds).zonmean().result() xcdo.CDO(ds).zonmean().result()
def test_new_instance(method): result = getattr(xcdo.CDO(ds), method)()._value clone = result._generate() assert result.__dict__ == clone.__dict__
def test_wrapperobjwithargs(method, expected): wrapperobj = getattr(xcdo.CDO(ds), method)(2)._value assert wrapperobj.rcmdstring == expected