-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Inner loop] Require langdetect
when running tests
#5801
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
Conversation
Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR ensures local tests don’t fail when langdetect
isn’t installed by deferring the lyrics
plugin import until after a skip guard.
- Moved the
from beetsplug import lyrics
import below thelangdetect
availability check. - Skips the entire test module early if
langdetect
is missing outside of CI.
Comments suppressed due to low confidence (2)
test/plugins/test_lyrics.py:30
- The skip guard is placed after importing
.lyrics_pages
, which may also depend onlangdetect
. Move the skip check above any imports that could import code requiringlangdetect
to avoid import errors.
from .lyrics_pages import LyricsPage, lyrics_pages
test/plugins/test_lyrics.py:33
- [nitpick] Consider using
pytest.importorskip('langdetect', reason='langdetect is required for lyrics tests')
instead of a manual skip guard for clearer intent and simpler code.
if not github_ci and not importlib.util.find_spec("langdetect"):
There are some failing tests on python 3.9 that needs a bit of investigation. I don't see how this is related to the changes here tho. @wisp3rwind & @snejus Do you know where this could stem from? I think we had some issue with the tests for the |
Just had a look at the failing build. The integration test that checks If you want, you can cherry-pick this commit.
Edit: |
Also note we'll want to add a small changelog note since this has been reported as an issue. |
langdetect
missinglangdetect
when running tests
I've made I currently recommend taking the full lockfile change. Thoughts? |
Try reverting the change in the lockfile and running |
Reran with |
Since I'm on Windows, the line endings might be changing. If y'all want to push a change with a smaller lockfile diff, I'm game. |
@citelao could you try running |
I did what had to be done 😛. I ran |
1487db2
to
fa500a3
Compare
Thank you! This issue will inevitably pop up again once we've got another contributor updating deps on Windows, so I'm looking for a fix-it-once-and-forever solution which does not depend on the developer editor setup. This is probably going to be a While you here @citelao could you by any chance help me to test it? I am not using a Windows machine so it's a bit complicated 😅
diff --git a/pyproject.toml b/pyproject.toml
index ea69240d5..ee82cf6e0 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -154,14 +154,27 @@ web = ["flask", "flask-cors"]
[tool.poetry.scripts]
beet = "beets.ui:main"
+[tool.poetry.requires-plugins]
+poethepoet = ">=0.32"
+
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.pipx-install]
-poethepoet = ">=0.26"
+poethepoet = ">=0.32"
poetry = ">=1.8,<2"
+[tool.poe.poetry_hooks]
+post_add = "fix-line-endings poetry.lock"
+post_lock = "fix-line-endings poetry.lock"
+post_remove = "fix-line-endings poetry.lock"
+post_update = "fix-line-endings poetry.lock"
+
+[tool.poe.tasks.fix-line-endings]
+args = { file = { help = "File to fix line endings for", positional = true, required = true } }
+shell = "sed 's/\r//g' poetry.lock -i.bak && rm poetry.lock.bak"
+
[tool.poe.tasks.build]
help = "Build the package"
shell = """
Are line endings looking as they should? Note: I was going to push to your branch but found I don't have permissions to push to your fork |
I guarantee you that won't work :) Windows machines don't have Quick investigation seems to point to a The issue thread did suggest a But I don't really understand the issue; my git supposedly normalized line endings for me, and I had to turn it off and then normalize manually to fix the issue. |
I should be able to get back to more windows work this weekend. |
I assumed you were using one of the supported shells Wow, plain PowerShell, that's proper hardcore! |
Well, in any case - we've got this fixed for now, so we're good. |
If you rebase / merge recently updated |
avoid linter error avoid other linter error fix format changing deps (no lock!) poetry lock? lint & format attempt 2 at poetry lock crlf -> lf line endings changelog!
fa500a3
to
2f98f11
Compare
Rebased! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your help and patience!
Happy to help from my |
Description
Fixes #5797.
Today, local tests (
poe test
) will fail to run iflangdetect
is not installed. This change makeslangdetect
required for test runs.Although this is easy to resolve with
poetry install --all-extras
, the code intends to work without that; it's a worthwhile fix.To Do
Documentation.Tests.What changed?
langdetect
to the required test dependencies.poetry lock
to handle this new requirement.How tested?
Ran locally.