mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
add missing commit with tests for import all modules in dir
This commit is contained in:
parent
8659132005
commit
9d7fd07777
1 changed files with 21 additions and 1 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import pytest
|
||||
|
||||
import aiogram
|
||||
from aiogram.utils.imports import import_module
|
||||
from aiogram.utils.imports import import_module, import_all_modules
|
||||
|
||||
|
||||
class TestImports:
|
||||
|
|
@ -27,3 +27,23 @@ class TestImports:
|
|||
value = import_module("aiogram:__version__")
|
||||
isinstance(value, str)
|
||||
assert value == aiogram.__version__
|
||||
|
||||
|
||||
class TestAllModulesImports:
|
||||
def test_relative_import_without_package(self):
|
||||
with pytest.raises(TypeError, match="the 'package' argument is required to perform a relative import for"):
|
||||
import_all_modules(".kaboom")
|
||||
|
||||
def test_non_existing_root(self):
|
||||
with pytest.raises(ModuleNotFoundError):
|
||||
import_all_modules("kaboom")
|
||||
|
||||
def test_non_existing_package(self):
|
||||
with pytest.raises(ModuleNotFoundError):
|
||||
import_all_modules("test", "kaboom")
|
||||
|
||||
def test_imported(self, capfd):
|
||||
import_all_modules("tests.modules_for_tests")
|
||||
captured = capfd.readouterr()
|
||||
assert captured.out == "__init__ imported\nsmall_module imported\n" \
|
||||
"small_package imported\nnested_small_module imported\n"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue