Skip to content
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

Refactor test cases to improve unit test quality #3302

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion mkdocs/tests/config/config_options_tests.py
Expand Up @@ -1184,7 +1184,7 @@ class Schema(Config):
conf.option.static_templates,
{'404.html', 'sitemap.xml', 'sitemap.html'},
)
self.assertEqual(conf.option['show_sidebar'], False)
self.assertFalse(conf.option['show_sidebar'])

def test_theme_name_is_none(self) -> None:
config = {
Expand Down
3 changes: 1 addition & 2 deletions mkdocs/tests/config/config_tests.py
Expand Up @@ -70,8 +70,7 @@ def test_config_option(self, temp_path):
os.mkdir(os.path.join(temp_path, 'docs'))

result = config.load_config(config_file=config_file.name)
self.assertEqual(result['site_name'], expected_result['site_name'])
self.assertEqual(result['nav'], expected_result['nav'])
self.assertTrue(expected_result.items() <= result.items())

@tempdir()
@tempdir()
Expand Down
4 changes: 2 additions & 2 deletions mkdocs/tests/livereload_tests.py
Expand Up @@ -434,7 +434,7 @@ def test_serves_polling_after_event(self, site_dir, docs_dir):

_, output = do_request(server, f"GET /livereload/{initial_epoch}/0")

self.assertNotEqual(server._visible_epoch, initial_epoch)
self.assertGreater(server._visible_epoch, initial_epoch)
self.assertEqual(output, str(server._visible_epoch))

@tempdir()
Expand All @@ -445,7 +445,7 @@ def test_serves_polling_with_timeout(self, site_dir):

start_time = time.monotonic()
_, output = do_request(server, f"GET /livereload/{initial_epoch}/0")
self.assertGreaterEqual(time.monotonic(), start_time + 0.2)
self.assertGreaterEqual(time.monotonic(), start_time + server.poll_response_timeout)
self.assertEqual(output, str(initial_epoch))

@tempdir()
Expand Down
2 changes: 1 addition & 1 deletion mkdocs/tests/plugin_tests.py
Expand Up @@ -227,7 +227,7 @@ def test_event_empty_item_returns_None(self):
plugin = DummyPlugin()
plugin.load_config({'foo': 'new'})
collection['foo'] = plugin
self.assertEqual(collection.on_pre_build(config={}), None)
self.assertIsNone(collection.on_pre_build(config={}))

def test_run_undefined_event_on_collection(self):
collection = plugins.PluginCollection()
Expand Down
2 changes: 1 addition & 1 deletion mkdocs/tests/theme_tests.py
Expand Up @@ -68,7 +68,7 @@ def static_templates(self):
def test_vars(self):
theme = Theme(name='mkdocs', foo='bar', baz=True)
self.assertEqual(theme['foo'], 'bar')
self.assertEqual(theme['baz'], True)
self.assertTrue(theme['baz'])
self.assertTrue('new' not in theme)
with self.assertRaises(KeyError):
theme['new']
Expand Down