Exemplo n.º 1
0
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)
Exemplo n.º 2
0
def test_wrong_input():
    with pytest.raises(AssertionError) as excinfo:
        xcdo.CDO(filename)
    assert 'Input not a xr.Dataset' in str(excinfo.value)
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
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)
Exemplo n.º 5
0
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
Exemplo n.º 6
0
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)
Exemplo n.º 7
0
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)
Exemplo n.º 8
0
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)
Exemplo n.º 9
0
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)
Exemplo n.º 10
0
def test_back_to_back_execution():
    xcdo.CDO(ds).zonmean().result()
    xcdo.CDO(ds).zonmean().result()
Exemplo n.º 11
0
def test_new_instance(method):
    result = getattr(xcdo.CDO(ds), method)()._value
    clone = result._generate()
    assert result.__dict__ == clone.__dict__
Exemplo n.º 12
0
def test_wrapperobjwithargs(method, expected):
    wrapperobj = getattr(xcdo.CDO(ds), method)(2)._value
    assert wrapperobj.rcmdstring == expected