Skip to content

Commit 62135a6

Browse files
committed
Try to add tests for ctime (Windows only)
1 parent d13e937 commit 62135a6

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

tests/test_unit/test_order.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import time
33

44
from mkdocs_include_markdown_plugin.event import on_page_markdown
5-
from testing_helpers import parametrize_directives, unix_only
5+
from testing_helpers import parametrize_directives, unix_only, windows_only
66

77

88
@parametrize_directives
@@ -496,3 +496,43 @@ def test_natural_order_by_extension_reverse(directive, page, tmp_path, plugin):
496496
tmp_path,
497497
plugin,
498498
) == 'file10.txt\nfile1.md\nfile2.md\n'
499+
500+
501+
@parametrize_directives
502+
@windows_only
503+
def test_ctime_order(directive, page, tmp_path, plugin):
504+
f1 = tmp_path / 'file2.md'
505+
f1.write_text('file2.md\n')
506+
time.sleep(1)
507+
f2 = tmp_path / 'file1.md'
508+
f2.write_text('file1.md\n')
509+
510+
assert on_page_markdown(
511+
f'''{{%
512+
{directive} "*.md"
513+
order='ctime'
514+
%}}''',
515+
page(tmp_path / 'includer.md'),
516+
tmp_path,
517+
plugin,
518+
) == 'file2.md\nfile1.md\n'
519+
520+
521+
@windows_only
522+
@parametrize_directives
523+
def test_ctime_reverse_order(directive, page, tmp_path, plugin):
524+
f1 = tmp_path / 'file2.md'
525+
f1.write_text('file2.md\n')
526+
time.sleep(1)
527+
f2 = tmp_path / 'file1.md'
528+
f2.write_text('file1.md\n')
529+
530+
assert on_page_markdown(
531+
f'''{{%
532+
{directive} "*.md"
533+
order='-ctime'
534+
%}}''',
535+
page(tmp_path / 'includer.md'),
536+
tmp_path,
537+
plugin,
538+
) == 'file1.md\nfile2.md\n'

tests/testing_helpers.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,9 @@
1515
reason='Test only supported on Unix systems',
1616
)
1717

18+
windows_only = pytest.mark.skipif(
19+
not sys.platform.startswith('win'),
20+
reason='Test only supported on Windows systems',
21+
)
22+
1823
rootdir = os.path.join(os.path.dirname(__file__), '..')

0 commit comments

Comments
 (0)