Introduction
This is the introduction text. It has some bold formatting.
Another paragraph in intro.
Study Methods
We did a randomized trial.
Statistical Analysis
Data was analyzed using R.
Results and Findings
Results were extremely positive.
Discussion
Our findings are significant.
Supporting Info
Some extra info that should be skipped.
"""
def test_parse_pmc_xml():
parsed = parse_pmc_xml(SAMPLE_PMC_XML)
assert "This is the introduction text. It has some bold formatting.\n\nAnother paragraph in intro." in parsed["Introduction"]
assert "We did a randomized trial.\n\nData was analyzed using R." in parsed["Methods"]
assert parsed["Results"] == "Results were extremely positive."
assert parsed["Discussion"] == "Our findings are significant."
# Check that "Supporting Info" text is not categorised
assert "Some extra info that should be skipped." not in parsed["Introduction"]
assert "Some extra info that should be skipped." not in parsed["Methods"]
assert "Some extra info that should be skipped." not in parsed["Results"]
assert "Some extra info that should be skipped." not in parsed["Discussion"]
def test_parse_pmc_xml_malformed():
parsed = parse_pmc_xml("