ihmwg / python-ihm

Python package for handling IHM mmCIF and BinaryCIF files
MIT License
14 stars 7 forks source link

Error when running test/test_reference.py #111

Closed CAHanke closed 1 year ago

CAHanke commented 1 year ago

When I try to run the test_reference.py on my machine (Windows 10, Python 2.7 and Python 3.9, if that matters), I get the following two errors, even though the number of amino acids for the entry should indeed be 726 according to UniProt.

FAILED test/test_reference.py::Tests::test_uniprot_sequence_from_accession - AssertionError: 739 != 726 FAILED test/test_reference.py::Tests::test_uniprot_sequence_from_accession_no_details - AssertionError: 739 != 726

benmwebb commented 1 year ago

This works fine on my machine, and also in the CI at GitHub Actions. Those two tests should mock urllib.request (Python 3) or urllib2 (Python 2) so that they don't actually talk to UniProt, but use local files (test/input/P52891.fasta and test/input/uniprot_no_details.fasta), but those should match what's at UniProt. Are you sure your copy of python-ihm isn't modified in some way? You could also modify the test and run it directly with python, and have it print the sequence so you can see what's different in your case.

CAHanke commented 1 year ago

Thank you. After your hint to the files and checking the content of the object that contains the sequence, I found the issue. It is connected to some setting in git, which converts line endings to windows format when checking out the repository. Therefore, I had 13 \r contained in the sequence. When changing the line endings in the test/input/P52891.fasta and test/input/uniprot_no_details.fasta to unix format, the tests run without issues. Alternatively, changing the git setting for the checkout should also work I guess (https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings?platform=windows).