1
1
import sys
2
+ import time
3
+
2
4
from datetime import date
5
+ from unittest import mock
3
6
4
7
import pytest
5
8
@@ -533,6 +536,7 @@ def test_changelog_with_filename_as_empty_string(mocker, changelog_path, config_
533
536
534
537
@pytest .mark .usefixtures ("tmp_commitizen_project" )
535
538
@pytest .mark .freeze_time ("2022-02-13" )
539
+ @mock .patch ("commitizen.git.GitTag.date" , "2022-02-13" )
536
540
def test_changelog_from_rev_first_version_from_arg (
537
541
mocker , config_path , changelog_path , file_regression
538
542
):
@@ -541,17 +545,18 @@ def test_changelog_from_rev_first_version_from_arg(
541
545
542
546
# create commit and tag
543
547
create_file_and_commit ("feat: new file" )
548
+
544
549
testargs = ["cz" , "bump" , "--yes" ]
545
550
mocker .patch .object (sys , "argv" , testargs )
546
551
cli .main ()
547
-
552
+ time . sleep ( 0.5 )
548
553
create_file_and_commit ("feat: after 0.2.0" )
549
554
create_file_and_commit ("feat: another feature" )
550
555
551
556
testargs = ["cz" , "bump" , "--yes" ]
552
557
mocker .patch .object (sys , "argv" , testargs )
553
558
cli .main ()
554
-
559
+ time . sleep ( 0.5 )
555
560
testargs = ["cz" , "changelog" , "0.2.0" ]
556
561
mocker .patch .object (sys , "argv" , testargs )
557
562
cli .main ()
@@ -564,6 +569,7 @@ def test_changelog_from_rev_first_version_from_arg(
564
569
565
570
@pytest .mark .usefixtures ("tmp_commitizen_project" )
566
571
@pytest .mark .freeze_time ("2022-02-13" )
572
+ @mock .patch ("commitizen.git.GitTag.date" , "2022-02-13" )
567
573
def test_changelog_from_rev_latest_version_from_arg (
568
574
mocker , config_path , changelog_path , file_regression
569
575
):
@@ -575,14 +581,14 @@ def test_changelog_from_rev_latest_version_from_arg(
575
581
testargs = ["cz" , "bump" , "--yes" ]
576
582
mocker .patch .object (sys , "argv" , testargs )
577
583
cli .main ()
578
-
584
+ time . sleep ( 0.5 )
579
585
create_file_and_commit ("feat: after 0.2.0" )
580
586
create_file_and_commit ("feat: another feature" )
581
587
582
588
testargs = ["cz" , "bump" , "--yes" ]
583
589
mocker .patch .object (sys , "argv" , testargs )
584
590
cli .main ()
585
-
591
+ time . sleep ( 0.5 )
586
592
testargs = ["cz" , "changelog" , "0.3.0" ]
587
593
mocker .patch .object (sys , "argv" , testargs )
588
594
cli .main ()
@@ -651,6 +657,7 @@ def test_changelog_from_rev_range_version_not_found(mocker, config_path):
651
657
652
658
@pytest .mark .usefixtures ("tmp_commitizen_project" )
653
659
@pytest .mark .freeze_time ("2022-02-13" )
660
+ @mock .patch ("commitizen.git.GitTag.date" , "2022-02-13" )
654
661
def test_changelog_from_rev_version_range_including_first_tag (
655
662
mocker , config_path , changelog_path , file_regression
656
663
):
@@ -682,6 +689,7 @@ def test_changelog_from_rev_version_range_including_first_tag(
682
689
683
690
@pytest .mark .usefixtures ("tmp_commitizen_project" )
684
691
@pytest .mark .freeze_time ("2022-02-13" )
692
+ @mock .patch ("commitizen.git.GitTag.date" , "2022-02-13" )
685
693
def test_changelog_from_rev_version_range_from_arg (
686
694
mocker , config_path , changelog_path , file_regression
687
695
):
@@ -693,19 +701,21 @@ def test_changelog_from_rev_version_range_from_arg(
693
701
testargs = ["cz" , "bump" , "--yes" ]
694
702
mocker .patch .object (sys , "argv" , testargs )
695
703
cli .main ()
696
-
704
+ time . sleep ( 0.5 )
697
705
create_file_and_commit ("feat: after 0.2.0" )
698
706
create_file_and_commit ("feat: another feature" )
699
707
700
708
testargs = ["cz" , "bump" , "--yes" ]
701
709
mocker .patch .object (sys , "argv" , testargs )
702
710
cli .main ()
711
+ time .sleep (0.5 )
703
712
704
713
create_file_and_commit ("feat: getting ready for this" )
705
714
706
715
testargs = ["cz" , "bump" , "--yes" ]
707
716
mocker .patch .object (sys , "argv" , testargs )
708
717
cli .main ()
718
+ time .sleep (0.5 )
709
719
710
720
testargs = ["cz" , "changelog" , "0.3.0..0.4.0" ]
711
721
mocker .patch .object (sys , "argv" , testargs )
@@ -718,6 +728,7 @@ def test_changelog_from_rev_version_range_from_arg(
718
728
719
729
@pytest .mark .usefixtures ("tmp_commitizen_project" )
720
730
@pytest .mark .freeze_time ("2022-02-13" )
731
+ @mock .patch ("commitizen.git.GitTag.date" , "2022-02-13" )
721
732
def test_changelog_from_rev_version_with_big_range_from_arg (
722
733
mocker , config_path , changelog_path , file_regression
723
734
):
@@ -726,40 +737,44 @@ def test_changelog_from_rev_version_with_big_range_from_arg(
726
737
727
738
# create commit and tag
728
739
create_file_and_commit ("feat: new file" )
740
+
729
741
testargs = ["cz" , "bump" , "--yes" ]
730
742
mocker .patch .object (sys , "argv" , testargs )
731
743
cli .main ()
744
+ time .sleep (0.5 )
732
745
733
746
create_file_and_commit ("feat: after 0.2.0" )
734
747
create_file_and_commit ("feat: another feature" )
735
748
736
749
testargs = ["cz" , "bump" , "--yes" ] # 0.3.0
737
750
mocker .patch .object (sys , "argv" , testargs )
738
751
cli .main ()
739
-
752
+ time . sleep ( 0.5 )
740
753
create_file_and_commit ("feat: getting ready for this" )
741
754
742
755
testargs = ["cz" , "bump" , "--yes" ] # 0.4.0
743
756
mocker .patch .object (sys , "argv" , testargs )
744
757
cli .main ()
745
-
758
+ time . sleep ( 0.5 )
746
759
create_file_and_commit ("fix: small error" )
747
760
748
761
testargs = ["cz" , "bump" , "--yes" ] # 0.4.1
749
762
mocker .patch .object (sys , "argv" , testargs )
750
763
cli .main ()
751
-
764
+ time . sleep ( 0.5 )
752
765
create_file_and_commit ("feat: new shinny feature" )
753
766
754
767
testargs = ["cz" , "bump" , "--yes" ] # 0.5.0
755
768
mocker .patch .object (sys , "argv" , testargs )
756
769
cli .main ()
757
-
770
+ time . sleep ( 0.5 )
758
771
create_file_and_commit ("feat: amazing different shinny feature" )
772
+ # dirty hack to avoid same time between tags
759
773
760
774
testargs = ["cz" , "bump" , "--yes" ] # 0.6.0
761
775
mocker .patch .object (sys , "argv" , testargs )
762
776
cli .main ()
777
+ time .sleep (0.5 )
763
778
764
779
testargs = ["cz" , "changelog" , "0.3.0..0.5.0" ]
765
780
mocker .patch .object (sys , "argv" , testargs )
@@ -772,6 +787,7 @@ def test_changelog_from_rev_version_with_big_range_from_arg(
772
787
773
788
@pytest .mark .usefixtures ("tmp_commitizen_project" )
774
789
@pytest .mark .freeze_time ("2022-02-13" )
790
+ @mock .patch ("commitizen.git.GitTag.date" , "2022-02-13" )
775
791
def test_changelog_from_rev_latest_version_dry_run (
776
792
mocker , capsys , config_path , changelog_path , file_regression
777
793
):
@@ -784,15 +800,15 @@ def test_changelog_from_rev_latest_version_dry_run(
784
800
testargs = ["cz" , "bump" , "--yes" ]
785
801
mocker .patch .object (sys , "argv" , testargs )
786
802
cli .main ()
787
-
803
+ time . sleep ( 0.5 )
788
804
create_file_and_commit ("feat: after 0.2.0" )
789
805
create_file_and_commit ("feat: another feature" )
790
806
791
807
testargs = ["cz" , "bump" , "--yes" ]
792
808
mocker .patch .object (sys , "argv" , testargs )
793
809
cli .main ()
794
810
capsys .readouterr ()
795
-
811
+ time . sleep ( 0.5 )
796
812
testargs = ["cz" , "changelog" , "0.3.0" , "--dry-run" ]
797
813
mocker .patch .object (sys , "argv" , testargs )
798
814
with pytest .raises (DryRunExit ):
0 commit comments