コード例 #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)
コード例 #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)
コード例 #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)
コード例 #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)
コード例 #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
コード例 #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)
コード例 #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)
コード例 #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)
コード例 #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)
コード例 #10
0
def test_back_to_back_execution():
    xcdo.CDO(ds).zonmean().result()
    xcdo.CDO(ds).zonmean().result()
コード例 #11
0
def test_new_instance(method):
    result = getattr(xcdo.CDO(ds), method)()._value
    clone = result._generate()
    assert result.__dict__ == clone.__dict__
コード例 #12
0
def test_wrapperobjwithargs(method, expected):
    wrapperobj = getattr(xcdo.CDO(ds), method)(2)._value
    assert wrapperobj.rcmdstring == expected