示例#1
0
def test_set_years_fail(years, exception_type):
    d = Duration()
    with pytest.raises(exception_type):
        d.years = years
示例#2
0
def test_to_yaml(duration, yaml_string, dumper):
    class TestDumper(dumper):
        pass
    Duration.register_yaml_representer(TestDumper)
    assert yaml.dump(duration, Dumper = TestDumper, default_flow_style = False) == yaml_string
示例#3
0
def test_set_years(years):
    d = Duration()
    d.years = years
    assert d.years == years
示例#4
0
def test_from_yaml_tag(expected_duration, yaml_string, tag, loader):
    class TestLoader(loader):
        pass
    Duration.register_yaml_constructor(TestLoader, tag = tag)
    loaded_duration = yaml.load(yaml_string, Loader = TestLoader)
    assert expected_duration == loaded_duration