def test_parse_bad_file():
    from rospkg.manifest import parse_manifest, InvalidManifest, MANIFEST_FILE
    base_p = get_test_dir()
    for b in ['bad1.xml', 'bad2.xml', 'bad3.xml']:
        p = os.path.join(base_p, b)
        with open(p, 'r') as f:
            contents = f.read()
        try:
            parse_manifest(MANIFEST_FILE, contents, filename=p)
            assert False, "parse should have failed on bad manifest"
        except InvalidManifest as e:
            print(str(e))
            assert p in str(e), "file name [%s] should be in error message [%s]" % (p, str(e))
def test_parse_manifest():
    # test_parse_manifest_file is more thorough; just want to make sure we have one call to lower-levle API
    from rospkg.manifest import parse_manifest, MANIFEST_FILE, STACK_FILE
    d = get_test_dir()
    p = os.path.join(d, 'example1', MANIFEST_FILE)
    with open(p, 'r') as f:
        contents = f.read()
    _subtest_parse_example1(parse_manifest(MANIFEST_FILE, contents, p))
def test_parse_manifest():
    # test_parse_manifest_file is more thorough; just want to make sure we have one call to lower-level API
    from rospkg.manifest import MANIFEST_FILE, parse_manifest
    d = get_test_dir()
    p = os.path.join(d, 'example1', MANIFEST_FILE)
    with open(p, 'r') as f:
        contents = f.read()
    _subtest_parse_example1(parse_manifest(MANIFEST_FILE, contents, p))