@@ -855,20 +855,12 @@ def test_bump_use_version_provider(mocker: MockFixture):
855
855
mock .set_version .assert_called_once_with ("0.0.1" )
856
856
857
857
858
- def test_bump_command_prelease_version_provider_via_cli (
859
- tmp_commitizen_project , mocker : MockFixture
858
+ def test_bump_command_prelease_version_type_via_cli (
859
+ tmp_commitizen_project_initial , mocker : MockFixture
860
860
):
861
- # PRERELEASE
861
+ tmp_commitizen_project = tmp_commitizen_project_initial ()
862
862
tmp_version_file = tmp_commitizen_project .join ("__version__.py" )
863
- tmp_version_file .write ("0.1.0" )
864
863
tmp_commitizen_cfg_file = tmp_commitizen_project .join ("pyproject.toml" )
865
- tmp_version_file_string = str (tmp_version_file ).replace ("\\ " , "/" )
866
- tmp_commitizen_cfg_file .write (
867
- f"{ tmp_commitizen_cfg_file .read ()} \n "
868
- f'version_files = ["{ tmp_version_file_string } "]'
869
- )
870
-
871
- create_file_and_commit ("feat: new user interface" )
872
864
873
865
testargs = [
874
866
"cz" ,
@@ -885,11 +877,9 @@ def test_bump_command_prelease_version_provider_via_cli(
885
877
tag_exists = git .tag_exist ("0.2.0-a0" )
886
878
assert tag_exists is True
887
879
888
- with open (tmp_version_file , "r" ) as f :
889
- assert "0.2.0-a0" in f .read ()
890
-
891
- with open (tmp_commitizen_cfg_file , "r" ) as f :
892
- assert "0.2.0-a0" in f .read ()
880
+ for version_file in [tmp_version_file , tmp_commitizen_cfg_file ]:
881
+ with open (version_file , "r" ) as f :
882
+ assert "0.2.0-a0" in f .read ()
893
883
894
884
# PRERELEASE BUMP CREATES VERSION WITHOUT PRERELEASE
895
885
testargs = ["cz" , "bump" , "--yes" ]
@@ -899,28 +889,19 @@ def test_bump_command_prelease_version_provider_via_cli(
899
889
tag_exists = git .tag_exist ("0.2.0" )
900
890
assert tag_exists is True
901
891
902
- with open (tmp_version_file , "r" ) as f :
903
- assert "0.2.0" in f .read ()
904
-
905
- with open (tmp_commitizen_cfg_file , "r" ) as f :
906
- assert "0.2.0" in f .read ()
892
+ for version_file in [tmp_version_file , tmp_commitizen_cfg_file ]:
893
+ with open (version_file , "r" ) as f :
894
+ assert "0.2.0" in f .read ()
907
895
908
896
909
897
def test_bump_command_prelease_version_type_via_config (
910
- tmp_commitizen_project , mocker : MockFixture
898
+ tmp_commitizen_project_initial , mocker : MockFixture
911
899
):
912
- # PRERELEASE
900
+ tmp_commitizen_project = tmp_commitizen_project_initial (
901
+ config_extra = 'version_type = "semver"\n ' ,
902
+ )
913
903
tmp_version_file = tmp_commitizen_project .join ("__version__.py" )
914
- tmp_version_file .write ("0.1.0" )
915
904
tmp_commitizen_cfg_file = tmp_commitizen_project .join ("pyproject.toml" )
916
- tmp_version_file_string = str (tmp_version_file ).replace ("\\ " , "/" )
917
- tmp_commitizen_cfg_file .write (
918
- f"{ tmp_commitizen_cfg_file .read ()} \n "
919
- f'version_files = ["{ tmp_version_file_string } "]\n '
920
- f'version_type = "semver"'
921
- )
922
-
923
- create_file_and_commit ("feat: new user interface" )
924
905
925
906
testargs = ["cz" , "bump" , "--prerelease" , "alpha" , "--yes" ]
926
907
mocker .patch .object (sys , "argv" , testargs )
@@ -929,11 +910,9 @@ def test_bump_command_prelease_version_type_via_config(
929
910
tag_exists = git .tag_exist ("0.2.0-a0" )
930
911
assert tag_exists is True
931
912
932
- with open (tmp_version_file , "r" ) as f :
933
- assert "0.2.0-a0" in f .read ()
934
-
935
- with open (tmp_commitizen_cfg_file , "r" ) as f :
936
- assert "0.2.0-a0" in f .read ()
913
+ for version_file in [tmp_version_file , tmp_commitizen_cfg_file ]:
914
+ with open (version_file , "r" ) as f :
915
+ assert "0.2.0-a0" in f .read ()
937
916
938
917
testargs = ["cz" , "bump" , "--prerelease" , "alpha" , "--yes" ]
939
918
mocker .patch .object (sys , "argv" , testargs )
@@ -942,11 +921,9 @@ def test_bump_command_prelease_version_type_via_config(
942
921
tag_exists = git .tag_exist ("0.2.0-a1" )
943
922
assert tag_exists is True
944
923
945
- with open (tmp_version_file , "r" ) as f :
946
- assert "0.2.0-a1" in f .read ()
947
-
948
- with open (tmp_commitizen_cfg_file , "r" ) as f :
949
- assert "0.2.0-a1" in f .read ()
924
+ for version_file in [tmp_version_file , tmp_commitizen_cfg_file ]:
925
+ with open (version_file , "r" ) as f :
926
+ assert "0.2.0-a1" in f .read ()
950
927
951
928
# PRERELEASE BUMP CREATES VERSION WITHOUT PRERELEASE
952
929
testargs = ["cz" , "bump" , "--yes" ]
@@ -956,28 +933,19 @@ def test_bump_command_prelease_version_type_via_config(
956
933
tag_exists = git .tag_exist ("0.2.0" )
957
934
assert tag_exists is True
958
935
959
- with open (tmp_version_file , "r" ) as f :
960
- assert "0.2.0" in f .read ()
961
-
962
- with open (tmp_commitizen_cfg_file , "r" ) as f :
963
- assert "0.2.0" in f .read ()
936
+ for version_file in [tmp_version_file , tmp_commitizen_cfg_file ]:
937
+ with open (version_file , "r" ) as f :
938
+ assert "0.2.0" in f .read ()
964
939
965
940
966
941
def test_bump_command_prelease_version_type_check_old_tags (
967
- tmp_commitizen_project , mocker : MockFixture
942
+ tmp_commitizen_project_initial , mocker : MockFixture
968
943
):
969
- # PRERELEASE
944
+ tmp_commitizen_project = tmp_commitizen_project_initial (
945
+ config_extra = ('tag_format = "v$version"\n version_type = "semver"\n ' ),
946
+ )
970
947
tmp_version_file = tmp_commitizen_project .join ("__version__.py" )
971
- tmp_version_file .write ("0.1.0" )
972
948
tmp_commitizen_cfg_file = tmp_commitizen_project .join ("pyproject.toml" )
973
- tmp_version_file_string = str (tmp_version_file ).replace ("\\ " , "/" )
974
- tmp_commitizen_cfg_file .write (
975
- f"{ tmp_commitizen_cfg_file .read ()} \n "
976
- f'version_files = ["{ tmp_version_file_string } "]\n '
977
- f'tag_format = "v$version"\n '
978
- f'version_type = "semver"\n '
979
- )
980
- create_file_and_commit ("feat: new user interface" )
981
949
982
950
testargs = ["cz" , "bump" , "--prerelease" , "alpha" , "--yes" ]
983
951
mocker .patch .object (sys , "argv" , testargs )
@@ -986,11 +954,9 @@ def test_bump_command_prelease_version_type_check_old_tags(
986
954
tag_exists = git .tag_exist ("v0.2.0-a0" )
987
955
assert tag_exists is True
988
956
989
- with open (tmp_version_file , "r" ) as f :
990
- assert "0.2.0-a0" in f .read ()
991
-
992
- with open (tmp_commitizen_cfg_file , "r" ) as f :
993
- assert "0.2.0-a0" in f .read ()
957
+ for version_file in [tmp_version_file , tmp_commitizen_cfg_file ]:
958
+ with open (version_file , "r" ) as f :
959
+ assert "0.2.0-a0" in f .read ()
994
960
995
961
testargs = ["cz" , "bump" , "--prerelease" , "alpha" ]
996
962
mocker .patch .object (sys , "argv" , testargs )
@@ -999,11 +965,9 @@ def test_bump_command_prelease_version_type_check_old_tags(
999
965
tag_exists = git .tag_exist ("v0.2.0-a1" )
1000
966
assert tag_exists is True
1001
967
1002
- with open (tmp_version_file , "r" ) as f :
1003
- assert "0.2.0-a1" in f .read ()
1004
-
1005
- with open (tmp_commitizen_cfg_file , "r" ) as f :
1006
- assert "0.2.0-a1" in f .read ()
968
+ for version_file in [tmp_version_file , tmp_commitizen_cfg_file ]:
969
+ with open (version_file , "r" ) as f :
970
+ assert "0.2.0-a1" in f .read ()
1007
971
1008
972
# PRERELEASE BUMP CREATES VERSION WITHOUT PRERELEASE
1009
973
testargs = ["cz" , "bump" ]
@@ -1013,8 +977,6 @@ def test_bump_command_prelease_version_type_check_old_tags(
1013
977
tag_exists = git .tag_exist ("v0.2.0" )
1014
978
assert tag_exists is True
1015
979
1016
- with open (tmp_version_file , "r" ) as f :
1017
- assert "0.2.0" in f .read ()
1018
-
1019
- with open (tmp_commitizen_cfg_file , "r" ) as f :
1020
- assert "0.2.0" in f .read ()
980
+ for version_file in [tmp_version_file , tmp_commitizen_cfg_file ]:
981
+ with open (version_file , "r" ) as f :
982
+ assert "0.2.0" in f .read ()
0 commit comments