From 537659325664b47b01c24e82cb4a0e850cd129c0 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 9 Feb 2021 17:44:04 +0100 Subject: Modernize Python syntax with pyupgrade --py38-plus **/*.py --- tests/test_djvu_parse.py | 2 +- tests/test_grobid2json.py | 2 +- tests/test_issue_db.py | 4 ++-- tests/test_refs_transform.py | 2 +- tests/test_transform.py | 10 +++++----- tests/test_work_pipeline.py | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) (limited to 'tests') diff --git a/tests/test_djvu_parse.py b/tests/test_djvu_parse.py index 777f8bf..f661f33 100644 --- a/tests/test_djvu_parse.py +++ b/tests/test_djvu_parse.py @@ -5,7 +5,7 @@ from fatcat_scholar.djvu import djvu_extract_leaf_texts def test_djvu_extract_leaf_texts() -> None: # https://archive.org/details/ERIC_ED441501 - with open("tests/files/ERIC_ED441501_djvu.xml", "r") as f: + with open("tests/files/ERIC_ED441501_djvu.xml") as f: blob = f.read() leaves = djvu_extract_leaf_texts(io.StringIO(blob), [3, 6]) diff --git a/tests/test_grobid2json.py b/tests/test_grobid2json.py index 345fd91..bd5c0e4 100644 --- a/tests/test_grobid2json.py +++ b/tests/test_grobid2json.py @@ -3,7 +3,7 @@ from fatcat_scholar.grobid2json import teixml2json def test_grobid_teixml2json() -> None: - with open("tests/files/example_grobid.tei.xml", "r") as f: + with open("tests/files/example_grobid.tei.xml") as f: blob = f.read() obj = teixml2json(blob, True) diff --git a/tests/test_issue_db.py b/tests/test_issue_db.py index 9fdab94..d164ef6 100644 --- a/tests/test_issue_db.py +++ b/tests/test_issue_db.py @@ -16,8 +16,8 @@ def test_issue_db_basics() -> None: issue_db = IssueDB(settings.SCHOLAR_ISSUEDB_PATH) issue_db.init_db() - with open("tests/files/sim_collections.json", "r") as f: + with open("tests/files/sim_collections.json") as f: issue_db.load_pubs(f.readlines(), api) - with open("tests/files/sim_items.json", "r") as f: + with open("tests/files/sim_items.json") as f: issue_db.load_issues(f.readlines(), es_client) diff --git a/tests/test_refs_transform.py b/tests/test_refs_transform.py index c26ee1e..3b18557 100644 --- a/tests/test_refs_transform.py +++ b/tests/test_refs_transform.py @@ -6,7 +6,7 @@ from fatcat_scholar.transform import refs_from_grobid def test_transform_refs_grobid() -> None: - with open("tests/files/example_grobid.tei.xml", "r") as f: + with open("tests/files/example_grobid.tei.xml") as f: blob = f.read() dummy_release = ReleaseEntity( diff --git a/tests/test_transform.py b/tests/test_transform.py index 927c13b..c5e189b 100644 --- a/tests/test_transform.py +++ b/tests/test_transform.py @@ -7,7 +7,7 @@ from fatcat_scholar.transform import * def test_es_release_from_release() -> None: - with open("tests/files/release_hsmo6p4smrganpb3fndaj2lon4.json", "r") as f: + with open("tests/files/release_hsmo6p4smrganpb3fndaj2lon4.json") as f: release = entity_from_json(f.read(), ReleaseEntity) obj = es_release_from_release(release) @@ -20,7 +20,7 @@ def test_es_release_from_release() -> None: def test_es_biblio_from_release() -> None: - with open("tests/files/release_hsmo6p4smrganpb3fndaj2lon4.json", "r") as f: + with open("tests/files/release_hsmo6p4smrganpb3fndaj2lon4.json") as f: release = entity_from_json(f.read(), ReleaseEntity) obj = es_biblio_from_release(release) @@ -36,16 +36,16 @@ def test_es_biblio_from_release() -> None: def test_run_refs() -> None: - with open("tests/files/work_iarm6swodra2bcrzhxrfaah7py_bundle.json", "r") as f: + with open("tests/files/work_iarm6swodra2bcrzhxrfaah7py_bundle.json") as f: run_refs(f.readlines()) def test_run_transform() -> None: - with open("tests/files/work_iarm6swodra2bcrzhxrfaah7py_bundle.json", "r") as f: + with open("tests/files/work_iarm6swodra2bcrzhxrfaah7py_bundle.json") as f: run_transform(f.readlines()) - with open("tests/files/sim_page_bundle.json", "r") as f: + with open("tests/files/sim_page_bundle.json") as f: run_transform(f.readlines()) diff --git a/tests/test_work_pipeline.py b/tests/test_work_pipeline.py index e0e4a82..39b09dc 100644 --- a/tests/test_work_pipeline.py +++ b/tests/test_work_pipeline.py @@ -84,5 +84,5 @@ def test_run_transform(mocker: Any) -> None: ), ) - with open("tests/files/release_hsmo6p4smrganpb3fndaj2lon4_sans.json", "r") as f: + with open("tests/files/release_hsmo6p4smrganpb3fndaj2lon4_sans.json") as f: wp.run_releases(f.readlines()) -- cgit v1.2.3