示例#1
0
 def parse_from_yaml(cls, source: Union[str, Path, IO]):
     "Parse from a path, url, path-like or file-like"
     with load_from_source(source) as (path, file):
         data = safe_load(file)
         return cls.parse_obj(data, path).__root__
示例#2
0
    def test_load_from_path_string(self):
        import cumulusci

        p = Path(cumulusci.__file__).parent / "cumulusci.yml"
        with load_from_source(str(p)) as (filename, data):
            assert "tasks:" in data.read()
def _extract_names(source):
    with load_from_source(source) as (name, data):
        names = re.findall(r"[^\w_]([\w_]+__c)[^\w_]", data.read())
        return set(names)
示例#4
0
 def test_load_from_url(self):
     html = "<!DOCTYPE HTML ..."
     responses.add("GET", "http://www.salesforce.com", body=html)
     with load_from_source("http://www.salesforce.com") as (filename, data):
         assert data.read() == html
示例#5
0
 def test_writable_file_throws(self):
     with temporary_dir():
         with open("writable", "wt") as t:
             with pytest.raises(UnsupportedOperation):
                 with load_from_source(t) as (filename, data):
                     pass
示例#6
0
 def test_binary_becomes_string(self):
     with load_from_source(BytesIO(b"foo")) as (path, file):
         data = file.read()
         assert isinstance(data, str)
         assert data == "foo"
示例#7
0
 def test_load_from_fs_resource(self):
     p = Path(cumulusci.__file__).parent / "cumulusci.yml"
     with open_fs_resource(p) as p2:
         with load_from_source(p2) as (filename, data):
             assert "tasks:" in data.read()
示例#8
0
 def test_load_from_open_file(self):
     p = Path(cumulusci.__file__).parent / "cumulusci.yml"
     with open(p) as f:
         with load_from_source(f) as (filename, data):
             assert "tasks:" in data.read()
             assert str(p) == filename