Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to select encoding of .bib file in parse_file() #395

Merged
merged 5 commits into from
Sep 1, 2023

Conversation

himcraft
Copy link
Contributor

No description provided.

@MiWeiss
Copy link
Collaborator

MiWeiss commented Aug 31, 2023

Thanks @himcraft for the PR.

The code change looks good, but would you mind adding a few tests? I know that the change is rather trivial, thus the purposes of the tests would not be to verify if you change is correct (I am convinced that it is), but instead serve to prevent from regression, i.e., from unintentionally breaking this function in the future.

Thanks!

Edit: Also make sure to run linting (black and isort --profile black)

@himcraft
Copy link
Contributor Author

Added test_encoding.py and a gbk_test.bib file in tests/.
This is my first attempt at writing tests for a Python project. Please feel free to point out any errors or suggest improvements :)

Copy link
Collaborator

@MiWeiss MiWeiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your commit.

Your test would certainly already be sufficient as a regression test. I still have left some minor comments, mostly to keep the test atomic and the test organisation (read file structure) consistent with the remainder of the test suite.

Afterwards, this will be ready to be merged 🚀 Thanks!


def test_gbk():
library = parse_file("tests/gbk_test.bib", encoding="gbk")
lines = writer.write(library).splitlines()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest not making the assertion on the "re-written" bibtex, but on the parsed entities instead.

e.g. assert library.entries[0]["author"] == ...

That way, we can keep the test independent of the writer.

@@ -0,0 +1,17 @@
"""Testing the parse_file function."""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we re-name this file to test_entrypoint and the module docstring accordingly - there's likely to be added more tests to it eventually.

@@ -0,0 +1,6 @@
@ARTICLE{����2013,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this file into a (new) tests/resources folder.

Copy link
Collaborator

@MiWeiss MiWeiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

Thanks a lot for your contribution. If there's any more problems or missing features you spot, please do not hesitate to report them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants