diff --git a/.gitignore b/.gitignore index a74eb62..31f3f41 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ .idea/ .installed.cfg .nox/ +.python-version .tox/ .vscode/ __pycache__/ diff --git a/noxfile.py b/noxfile.py index a2fe42c..fb97b0c 100644 --- a/noxfile.py +++ b/noxfile.py @@ -88,7 +88,7 @@ def pylint(session): run_pylint(session) -@nox.session(python='python3.7') +@nox.session(python='python3.8') def test(session): """Run all the tests.""" session.install('-rrequirements-dev.txt') @@ -96,7 +96,7 @@ def test(session): run_pytest(session) -@nox.session(python='python3.7', name='test-units') +@nox.session(python='python3.8', name='test-units') def test_units(session): """Run the unit tests.""" session.install('-rrequirements-dev.txt') @@ -104,7 +104,7 @@ def test_units(session): run_pytest_units(session) -@nox.session(python='python3.7', name='test-integrations') +@nox.session(python='python3.8', name='test-integrations') def test_integrations(session): """Run the integration tests.""" session.install('-rrequirements-dev.txt') diff --git a/scrapd/core/article.py b/scrapd/core/article.py index 01c7b6b..ff738c0 100644 --- a/scrapd/core/article.py +++ b/scrapd/core/article.py @@ -61,7 +61,9 @@ def parse_deceased_tag(deceased_tag_p): deceased_text = deceased_tag_p.get_text() # NOTE(rgreinho): Where do the 20 and 100 numbers come from? There should not be magic numbers. if 20 < len(deceased_text) < 100 and "preliminary" not in deceased_text: - return re.split(r'Deceased(?: \d)?:', deceased_text, maxsplit=1)[1].strip() + split_text = re.split(r'Deceased(?: \d)?:', deceased_text, maxsplit=1) + if len(split_text) > 1: + return split_text[1].strip() deceased_field_str = '' starting_tag = deceased_tag_p.find("strong") or deceased_tag_p diff --git a/tests/core/test_article.py b/tests/core/test_article.py index 2ce112c..17f0da7 100644 --- a/tests/core/test_article.py +++ b/tests/core/test_article.py @@ -143,6 +143,22 @@ ), 'errors': None, }, + { + 'id': 'double-deceased', + 'page': 'fatality-crash-41-2', + 'expected': model.Report( + case='20-1850221', + crash=41, + date=datetime.date(2020, 7, 3), + fatalities=[ + model.Fatality(), + ], + location='9600 Block of E. U.S. 290 eastbound', + notes='', + time=datetime.time(5, 49), + ), + 'errors': 2, + }, ] deceased_tag_scenarios = [ diff --git a/tests/data/fatality-crash-41-2 b/tests/data/fatality-crash-41-2 new file mode 100644 index 0000000..dda63b2 --- /dev/null +++ b/tests/data/fatality-crash-41-2 @@ -0,0 +1,1282 @@ + + + + + + + + + + + + + + + + + Fatality Crash #41 | AustinTexas.gov + + + + + + + + + +
+ +
+ +
+ + + + + +
+
+ + +
+
+ + +
+
+
+ + + +
+
+
+
+
+ + + + +
+ +
+
+
+ +
+
+
+ +
+
+ + +
+ + +
+
+ + + +
+ + + + + + + + + + + + + + +