From df1ab365b9df18172b154b53d39a885262676c6e Mon Sep 17 00:00:00 2001 From: David Li Date: Tue, 9 Apr 2024 21:00:02 +0000 Subject: [PATCH 1/2] Refractor test --- tests/test_find_dois.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/tests/test_find_dois.py b/tests/test_find_dois.py index 33b3580..3509835 100644 --- a/tests/test_find_dois.py +++ b/tests/test_find_dois.py @@ -1,33 +1,32 @@ -import unittest import tempfile import os import bibtexparser +import pytest from DuBibtex import Parser +@pytest.mark.parametrize("filename,correct_doi", [ + ("signet.bib", "10.1109/ICCV48922.2021.01396"), +]) +def test_iccv_doi(filename, correct_doi): + input_file = os.path.join("tests", "inputs", filename) -class TestFindDOIs(unittest.TestCase): - - - def test_iccv_doi(self): - filename = "tests/inputs/signet.bib" - correct_doi = "10.1109/ICCV48922.2021.01396" - - self.assertTrue(os.path.isfile(filename)) - library = bibtexparser.parse_file(filename) + assert os.path.isfile(input_file), f"File {input_file} does not exist" + library = bibtexparser.parse_file(input_file) with tempfile.NamedTemporaryFile() as fp: p = Parser(output_file=fp.name) for entry in library.entries: - p.copy_from_parsed_entry(entry) - p.write_current_item() + p.copy_from_parsed_entry(entry) + p.write_current_item() p.shut_down() # Check the doi generated_library = bibtexparser.parse_file(fp.name) - self.assertEqual(len(generated_library.entries), len(library.entries), "Number of entries should be the same") + assert len(generated_library.entries) == len( + library.entries), "Number of entries should be the same" for entry in generated_library.entries: - self.assertTrue("doi" in entry) - self.assertEqual(entry.fields_dict["doi"].value, correct_doi) \ No newline at end of file + assert "doi" in entry + assert entry.fields_dict["doi"].value == correct_doi From 89a43243163f42af985bc6cd62a00f9255af4f9c Mon Sep 17 00:00:00 2001 From: David Li Date: Tue, 9 Apr 2024 21:05:55 +0000 Subject: [PATCH 2/2] Add qdiffusion test --- tests/inputs/qdiffusion.bib | 8 ++++++++ tests/test_find_dois.py | 1 + 2 files changed, 9 insertions(+) create mode 100644 tests/inputs/qdiffusion.bib diff --git a/tests/inputs/qdiffusion.bib b/tests/inputs/qdiffusion.bib new file mode 100644 index 0000000..fc366a6 --- /dev/null +++ b/tests/inputs/qdiffusion.bib @@ -0,0 +1,8 @@ +@InProceedings{li2023qdiffusion, + author={Li, Xiuyu and Liu, Yijiang and Lian, Long and Yang, Huanrui and Dong, Zhen and Kang, Daniel and Zhang, Shanghang and Keutzer, Kurt}, + title={Q-Diffusion: Quantizing Diffusion Models}, + booktitle={Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV)}, + month={October}, + year={2023}, + pages={17535-17545} +} \ No newline at end of file diff --git a/tests/test_find_dois.py b/tests/test_find_dois.py index 3509835..c0d4d0c 100644 --- a/tests/test_find_dois.py +++ b/tests/test_find_dois.py @@ -9,6 +9,7 @@ @pytest.mark.parametrize("filename,correct_doi", [ ("signet.bib", "10.1109/ICCV48922.2021.01396"), + ("qdiffusion.bib", "10.1109/ICCV51070.2023.01608"), ]) def test_iccv_doi(filename, correct_doi): input_file = os.path.join("tests", "inputs", filename)