@@ -834,19 +834,11 @@ def test_bump_manual_version_disallows_prerelease_offset(mocker):
834
834
835
835
836
836
def test_bump_command_prelease_version_type_via_cli (
837
- tmp_commitizen_project , mocker : MockFixture
837
+ tmp_commitizen_project_initial , mocker : MockFixture
838
838
):
839
- # PRERELEASE
839
+ tmp_commitizen_project = tmp_commitizen_project_initial ()
840
840
tmp_version_file = tmp_commitizen_project .join ("__version__.py" )
841
- tmp_version_file .write ("0.1.0" )
842
841
tmp_commitizen_cfg_file = tmp_commitizen_project .join ("pyproject.toml" )
843
- tmp_version_file_string = str (tmp_version_file ).replace ("\\ " , "/" )
844
- tmp_commitizen_cfg_file .write (
845
- f"{ tmp_commitizen_cfg_file .read ()} \n "
846
- f'version_files = ["{ tmp_version_file_string } "]'
847
- )
848
-
849
- create_file_and_commit ("feat: new user interface" )
850
842
851
843
testargs = [
852
844
"cz" ,
@@ -863,11 +855,9 @@ def test_bump_command_prelease_version_type_via_cli(
863
855
tag_exists = git .tag_exist ("0.2.0-a0" )
864
856
assert tag_exists is True
865
857
866
- with open (tmp_version_file , "r" ) as f :
867
- assert "0.2.0-a0" in f .read ()
868
-
869
- with open (tmp_commitizen_cfg_file , "r" ) as f :
870
- assert "0.2.0-a0" in f .read ()
858
+ for version_file in [tmp_version_file , tmp_commitizen_cfg_file ]:
859
+ with open (version_file , "r" ) as f :
860
+ assert "0.2.0-a0" in f .read ()
871
861
872
862
# PRERELEASE BUMP CREATES VERSION WITHOUT PRERELEASE
873
863
testargs = ["cz" , "bump" , "--yes" ]
@@ -877,28 +867,19 @@ def test_bump_command_prelease_version_type_via_cli(
877
867
tag_exists = git .tag_exist ("0.2.0" )
878
868
assert tag_exists is True
879
869
880
- with open (tmp_version_file , "r" ) as f :
881
- assert "0.2.0" in f .read ()
882
-
883
- with open (tmp_commitizen_cfg_file , "r" ) as f :
884
- assert "0.2.0" in f .read ()
870
+ for version_file in [tmp_version_file , tmp_commitizen_cfg_file ]:
871
+ with open (version_file , "r" ) as f :
872
+ assert "0.2.0" in f .read ()
885
873
886
874
887
875
def test_bump_command_prelease_version_type_via_config (
888
- tmp_commitizen_project , mocker : MockFixture
876
+ tmp_commitizen_project_initial , mocker : MockFixture
889
877
):
890
- # PRERELEASE
878
+ tmp_commitizen_project = tmp_commitizen_project_initial (
879
+ config_extra = 'version_type = "semver"\n ' ,
880
+ )
891
881
tmp_version_file = tmp_commitizen_project .join ("__version__.py" )
892
- tmp_version_file .write ("0.1.0" )
893
882
tmp_commitizen_cfg_file = tmp_commitizen_project .join ("pyproject.toml" )
894
- tmp_version_file_string = str (tmp_version_file ).replace ("\\ " , "/" )
895
- tmp_commitizen_cfg_file .write (
896
- f"{ tmp_commitizen_cfg_file .read ()} \n "
897
- f'version_files = ["{ tmp_version_file_string } "]\n '
898
- f'version_type = "semver"'
899
- )
900
-
901
- create_file_and_commit ("feat: new user interface" )
902
883
903
884
testargs = ["cz" , "bump" , "--prerelease" , "alpha" , "--yes" ]
904
885
mocker .patch .object (sys , "argv" , testargs )
@@ -907,11 +888,9 @@ def test_bump_command_prelease_version_type_via_config(
907
888
tag_exists = git .tag_exist ("0.2.0-a0" )
908
889
assert tag_exists is True
909
890
910
- with open (tmp_version_file , "r" ) as f :
911
- assert "0.2.0-a0" in f .read ()
912
-
913
- with open (tmp_commitizen_cfg_file , "r" ) as f :
914
- assert "0.2.0-a0" in f .read ()
891
+ for version_file in [tmp_version_file , tmp_commitizen_cfg_file ]:
892
+ with open (version_file , "r" ) as f :
893
+ assert "0.2.0-a0" in f .read ()
915
894
916
895
testargs = ["cz" , "bump" , "--prerelease" , "alpha" , "--yes" ]
917
896
mocker .patch .object (sys , "argv" , testargs )
@@ -920,11 +899,9 @@ def test_bump_command_prelease_version_type_via_config(
920
899
tag_exists = git .tag_exist ("0.2.0-a1" )
921
900
assert tag_exists is True
922
901
923
- with open (tmp_version_file , "r" ) as f :
924
- assert "0.2.0-a1" in f .read ()
925
-
926
- with open (tmp_commitizen_cfg_file , "r" ) as f :
927
- assert "0.2.0-a1" in f .read ()
902
+ for version_file in [tmp_version_file , tmp_commitizen_cfg_file ]:
903
+ with open (version_file , "r" ) as f :
904
+ assert "0.2.0-a1" in f .read ()
928
905
929
906
# PRERELEASE BUMP CREATES VERSION WITHOUT PRERELEASE
930
907
testargs = ["cz" , "bump" , "--yes" ]
@@ -934,28 +911,19 @@ def test_bump_command_prelease_version_type_via_config(
934
911
tag_exists = git .tag_exist ("0.2.0" )
935
912
assert tag_exists is True
936
913
937
- with open (tmp_version_file , "r" ) as f :
938
- assert "0.2.0" in f .read ()
939
-
940
- with open (tmp_commitizen_cfg_file , "r" ) as f :
941
- assert "0.2.0" in f .read ()
914
+ for version_file in [tmp_version_file , tmp_commitizen_cfg_file ]:
915
+ with open (version_file , "r" ) as f :
916
+ assert "0.2.0" in f .read ()
942
917
943
918
944
919
def test_bump_command_prelease_version_type_check_old_tags (
945
- tmp_commitizen_project , mocker : MockFixture
920
+ tmp_commitizen_project_initial , mocker : MockFixture
946
921
):
947
- # PRERELEASE
922
+ tmp_commitizen_project = tmp_commitizen_project_initial (
923
+ config_extra = ('tag_format = "v$version"\n version_type = "semver"\n ' ),
924
+ )
948
925
tmp_version_file = tmp_commitizen_project .join ("__version__.py" )
949
- tmp_version_file .write ("0.1.0" )
950
926
tmp_commitizen_cfg_file = tmp_commitizen_project .join ("pyproject.toml" )
951
- tmp_version_file_string = str (tmp_version_file ).replace ("\\ " , "/" )
952
- tmp_commitizen_cfg_file .write (
953
- f"{ tmp_commitizen_cfg_file .read ()} \n "
954
- f'version_files = ["{ tmp_version_file_string } "]\n '
955
- f'tag_format = "v$version"\n '
956
- f'version_type = "semver"\n '
957
- )
958
- create_file_and_commit ("feat: new user interface" )
959
927
960
928
testargs = ["cz" , "bump" , "--prerelease" , "alpha" , "--yes" ]
961
929
mocker .patch .object (sys , "argv" , testargs )
@@ -964,11 +932,9 @@ def test_bump_command_prelease_version_type_check_old_tags(
964
932
tag_exists = git .tag_exist ("v0.2.0-a0" )
965
933
assert tag_exists is True
966
934
967
- with open (tmp_version_file , "r" ) as f :
968
- assert "0.2.0-a0" in f .read ()
969
-
970
- with open (tmp_commitizen_cfg_file , "r" ) as f :
971
- assert "0.2.0-a0" in f .read ()
935
+ for version_file in [tmp_version_file , tmp_commitizen_cfg_file ]:
936
+ with open (version_file , "r" ) as f :
937
+ assert "0.2.0-a0" in f .read ()
972
938
973
939
testargs = ["cz" , "bump" , "--prerelease" , "alpha" ]
974
940
mocker .patch .object (sys , "argv" , testargs )
@@ -977,11 +943,9 @@ def test_bump_command_prelease_version_type_check_old_tags(
977
943
tag_exists = git .tag_exist ("v0.2.0-a1" )
978
944
assert tag_exists is True
979
945
980
- with open (tmp_version_file , "r" ) as f :
981
- assert "0.2.0-a1" in f .read ()
982
-
983
- with open (tmp_commitizen_cfg_file , "r" ) as f :
984
- assert "0.2.0-a1" in f .read ()
946
+ for version_file in [tmp_version_file , tmp_commitizen_cfg_file ]:
947
+ with open (version_file , "r" ) as f :
948
+ assert "0.2.0-a1" in f .read ()
985
949
986
950
# PRERELEASE BUMP CREATES VERSION WITHOUT PRERELEASE
987
951
testargs = ["cz" , "bump" ]
@@ -991,8 +955,6 @@ def test_bump_command_prelease_version_type_check_old_tags(
991
955
tag_exists = git .tag_exist ("v0.2.0" )
992
956
assert tag_exists is True
993
957
994
- with open (tmp_version_file , "r" ) as f :
995
- assert "0.2.0" in f .read ()
996
-
997
- with open (tmp_commitizen_cfg_file , "r" ) as f :
998
- assert "0.2.0" in f .read ()
958
+ for version_file in [tmp_version_file , tmp_commitizen_cfg_file ]:
959
+ with open (version_file , "r" ) as f :
960
+ assert "0.2.0" in f .read ()
0 commit comments