-
-
Notifications
You must be signed in to change notification settings - Fork 554
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add deprecation warnings for main module imports (#1813)
This instructs users to use direct imports or to use `DeviceFactory.create()` instead of importing directly through the `miio` module.
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 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,16 @@ | ||
"""Tests for the main module.""" | ||
import pytest | ||
|
||
import miio | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("old_name", "new_name"), | ||
[("RoborockVacuum", "miio.integrations.roborock.vacuum.vacuum.RoborockVacuum")], | ||
) | ||
def test_deprecation_warning(old_name, new_name): | ||
"""Check that deprecation warning gets emitted for deprecated imports.""" | ||
with pytest.deprecated_call( | ||
match=rf"Importing {old_name} directly from 'miio' is deprecated, import <class '{new_name}'> or use DeviceFactory.create\(\) instead" | ||
): | ||
miio.__getattr__(old_name) |