Skip to content

Commit

Permalink
Fix imports to get tests passing (mkdocs#2751)
Browse files Browse the repository at this point in the history
* Fix broken localization import in theme_tests.py
* Fix tests by importing directly from config submodule
* Fix test runner top level directory
  • Loading branch information
cpcloud authored Jan 23, 2022
1 parent cff5b55 commit c93fc91
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion mkdocs/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from mkdocs import config
from mkdocs import utils
from mkdocs.config import defaults as config_defaults


def dedent(text):
Expand All @@ -32,7 +33,7 @@ def load_config(**cfg):
if 'docs_dir' not in cfg:
# Point to an actual dir to avoid a 'does not exist' error on validation.
cfg['docs_dir'] = os.path.join(path_base, 'docs')
conf = config.Config(schema=config.defaults.get_schema(), config_file_path=cfg['config_file_path'])
conf = config.Config(schema=config_defaults.get_schema(), config_file_path=cfg['config_file_path'])
conf.load_dict(cfg)

errors_warnings = conf.validate()
Expand Down
7 changes: 4 additions & 3 deletions mkdocs/tests/plugin_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@
from mkdocs import plugins
from mkdocs import config
from mkdocs.commands import build
from mkdocs.config import config_options
from mkdocs.exceptions import BuildError, PluginError, Abort
from mkdocs.tests.base import load_config


class DummyPlugin(plugins.BasePlugin):
config_scheme = (
('foo', config.config_options.Type(str, default='default foo')),
('bar', config.config_options.Type(int, default=0)),
('dir', config.config_options.Dir(exists=False)),
('foo', config_options.Type(str, default='default foo')),
('bar', config_options.Type(int, default=0)),
('dir', config_options.Dir(exists=False)),
)

def on_pre_page(self, content, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion mkdocs/tests/theme_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import mkdocs
from mkdocs.theme import Theme
from localization import parse_locale
from mkdocs.localization import parse_locale

abs_path = os.path.abspath(os.path.dirname(__file__))
mkdocs_dir = os.path.abspath(os.path.dirname(mkdocs.__file__))
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ deps=
py{36,37,38,39,310,py3}-{unittests,min-req}: -rrequirements/test.txt
commands=
{envpython} --version
py{36,37,38,39,310,py3}-{unittests,min-req}: {envbindir}/coverage run --source=mkdocs --omit 'mkdocs/tests/*' -m unittest discover -p '*tests.py' mkdocs
py{36,37,38,39,310,py3}-{unittests,min-req}: {envbindir}/coverage run --source=mkdocs --omit 'mkdocs/tests/*' -m unittest discover -p '*tests.py' mkdocs --top-level-directory .
py{36,37,38,39,310,py3}-unittests: {envbindir}/coverage xml
py{36,37,38,39,310,py3}-unittests: {envbindir}/coverage report --show-missing
py{36,37,38,39,310,py3}-integration: {envpython} -m mkdocs.tests.integration --output={envtmpdir}/builds
Expand Down

0 comments on commit c93fc91

Please sign in to comment.