-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Propagates more ImportErrors during autodiscovery (#8632)
* Refactors find_related_module tests. * Narrows exception catching. * Makes a narrower assertion. * Cleans up test name. * Tries to address coverage miss. * Cleans up comment. * Fixes typo. * Adds integration test. * Fixes bug on ModuleNotFoundError.name when fails early. * Defaults getattr to None.
- Loading branch information
1 parent
aaec27a
commit 3ba50e4
Showing
3 changed files
with
100 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from celery import shared_task | ||
|
||
|
||
@shared_task() | ||
def dummy_task(x, y): | ||
return x + y | ||
|
||
|
||
class test_loader: | ||
def test_autodiscovery(self, manager): | ||
# Arrange | ||
expected_package_name, _, module_name = __name__.rpartition('.') | ||
unexpected_package_name = 'nonexistent.package.name' | ||
|
||
# Act | ||
manager.app.autodiscover_tasks([expected_package_name, unexpected_package_name], module_name, force=True) | ||
|
||
# Assert | ||
assert f'{expected_package_name}.{module_name}.dummy_task' in manager.app.tasks | ||
assert not any( | ||
task.startswith(unexpected_package_name) for task in manager.app.tasks | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters