3030# package module
3131from mkdocs_git_revision_date_localized_plugin .util import Util
3232from mkdocs_git_revision_date_localized_plugin .ci import commit_count
33+ from mkdocs_git_revision_date_localized_plugin .dates import get_date_formats
3334
3435# ##################################
3536# ######## Globals #################
@@ -147,6 +148,7 @@ def setup_commit_history(testproject_path):
147148 testproject_path = str (testproject_path )
148149
149150 repo = git .Repo .init (testproject_path , bare = False )
151+ repo .git .checkout ("-b" , "master" )
150152 author = "Test Person <[email protected] >" 151153
152154
@@ -342,18 +344,6 @@ def validate_mkdocs_file(temp_path: str, mkdocs_yml_file: str):
342344# ##################################
343345
344346
345- def test_date_formats ():
346- u = Util ()
347- assert u ._date_formats (1582397529 ) == {
348- "date" : "February 22, 2020" ,
349- "datetime" : "February 22, 2020 18:52:09" ,
350- "iso_date" : "2020-02-22" ,
351- "iso_datetime" : "2020-02-22 18:52:09" ,
352- "timeago" : '<span class="timeago" datetime="2020-02-22T18:52:09+00:00" locale="en"></span>' ,
353- "custom" : '22. February 2020' ,
354- }
355-
356-
357347@pytest .mark .parametrize ("mkdocs_file" , MKDOCS_FILES , ids = lambda x : f"mkdocs file: { x } " )
358348def test_tags_are_replaced (tmp_path , mkdocs_file ):
359349 """
@@ -390,7 +380,7 @@ def test_tags_are_replaced(tmp_path, mkdocs_file):
390380
391381 # the revision date was in 'setup_commit_history' was set to 1642911026 (Sun Jan 23 2022 04:10:26 GMT+0000)
392382 # Assert {{ git_revision_date_localized }} is replaced
393- date_formats_revision_date = Util (). _date_formats (1642911026 ,
383+ date_formats_revision_date = get_date_formats (1642911026 ,
394384 locale = plugin_config .get ("locale" ),
395385 time_zone = plugin_config .get ("timezone" ),
396386 custom_format = plugin_config .get ("custom_format" )
@@ -403,7 +393,7 @@ def test_tags_are_replaced(tmp_path, mkdocs_file):
403393
404394 # The last site revision was set in setup_commit_history to 1643911026 (Thu Feb 03 2022 17:57:06 GMT+0000)
405395 # Assert {{ git_site_revision_date_localized }} is replaced
406- date_formats_revision_date = Util (). _date_formats (1643911026 ,
396+ date_formats_revision_date = get_date_formats (1643911026 ,
407397 locale = plugin_config .get ("locale" ),
408398 time_zone = plugin_config .get ("timezone" ),
409399 custom_format = plugin_config .get ("custom_format" )
@@ -416,7 +406,7 @@ def test_tags_are_replaced(tmp_path, mkdocs_file):
416406 # Note {{ git_creation_date_localized }} is only replaced when configured in the config
417407 if plugin_config .get ("enable_creation_date" ):
418408 # The creation of page_with_tag.md was set in setup_commit_history to 1500854705 ( Mon Jul 24 2017 00:05:05 GMT+0000 )
419- date_formats_revision_date = Util (). _date_formats (1500854705 ,
409+ date_formats_revision_date = get_date_formats (1500854705 ,
420410 locale = plugin_config .get ("locale" ),
421411 time_zone = plugin_config .get ("timezone" ),
422412 custom_format = plugin_config .get ("custom_format" )
@@ -628,6 +618,10 @@ def test_low_fetch_depth(tmp_path, caplog):
628618
629619 # Clone the local repo with fetch depth of 1
630620 repo = git .Repo .init (cloned_folder , bare = False )
621+ try :
622+ repo .heads .main .rename ("master" , force = True )
623+ except :
624+ pass
631625 origin = repo .create_remote ("origin" , str (testproject_path ))
632626 origin .fetch (depth = 1 , prune = True )
633627 repo .create_head (
0 commit comments