@@ -855,20 +855,12 @@ def test_bump_use_version_provider(mocker: MockFixture):
855855 mock .set_version .assert_called_once_with ("0.0.1" )
856856
857857
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
860860):
861- # PRERELEASE
861+ tmp_commitizen_project = tmp_commitizen_project_initial ()
862862 tmp_version_file = tmp_commitizen_project .join ("__version__.py" )
863- tmp_version_file .write ("0.1.0" )
864863 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" )
872864
873865 testargs = [
874866 "cz" ,
@@ -885,11 +877,9 @@ def test_bump_command_prelease_version_provider_via_cli(
885877 tag_exists = git .tag_exist ("0.2.0-a0" )
886878 assert tag_exists is True
887879
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 ()
893883
894884 # PRERELEASE BUMP CREATES VERSION WITHOUT PRERELEASE
895885 testargs = ["cz" , "bump" , "--yes" ]
@@ -899,28 +889,19 @@ def test_bump_command_prelease_version_provider_via_cli(
899889 tag_exists = git .tag_exist ("0.2.0" )
900890 assert tag_exists is True
901891
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 ()
907895
908896
909897def test_bump_command_prelease_version_type_via_config (
910- tmp_commitizen_project , mocker : MockFixture
898+ tmp_commitizen_project_initial , mocker : MockFixture
911899):
912- # PRERELEASE
900+ tmp_commitizen_project = tmp_commitizen_project_initial (
901+ config_extra = 'version_type = "semver"\n ' ,
902+ )
913903 tmp_version_file = tmp_commitizen_project .join ("__version__.py" )
914- tmp_version_file .write ("0.1.0" )
915904 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" )
924905
925906 testargs = ["cz" , "bump" , "--prerelease" , "alpha" , "--yes" ]
926907 mocker .patch .object (sys , "argv" , testargs )
@@ -929,11 +910,9 @@ def test_bump_command_prelease_version_type_via_config(
929910 tag_exists = git .tag_exist ("0.2.0-a0" )
930911 assert tag_exists is True
931912
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 ()
937916
938917 testargs = ["cz" , "bump" , "--prerelease" , "alpha" , "--yes" ]
939918 mocker .patch .object (sys , "argv" , testargs )
@@ -942,11 +921,9 @@ def test_bump_command_prelease_version_type_via_config(
942921 tag_exists = git .tag_exist ("0.2.0-a1" )
943922 assert tag_exists is True
944923
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 ()
950927
951928 # PRERELEASE BUMP CREATES VERSION WITHOUT PRERELEASE
952929 testargs = ["cz" , "bump" , "--yes" ]
@@ -956,28 +933,19 @@ def test_bump_command_prelease_version_type_via_config(
956933 tag_exists = git .tag_exist ("0.2.0" )
957934 assert tag_exists is True
958935
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 ()
964939
965940
966941def test_bump_command_prelease_version_type_check_old_tags (
967- tmp_commitizen_project , mocker : MockFixture
942+ tmp_commitizen_project_initial , mocker : MockFixture
968943):
969- # PRERELEASE
944+ tmp_commitizen_project = tmp_commitizen_project_initial (
945+ config_extra = ('tag_format = "v$version"\n version_type = "semver"\n ' ),
946+ )
970947 tmp_version_file = tmp_commitizen_project .join ("__version__.py" )
971- tmp_version_file .write ("0.1.0" )
972948 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" )
981949
982950 testargs = ["cz" , "bump" , "--prerelease" , "alpha" , "--yes" ]
983951 mocker .patch .object (sys , "argv" , testargs )
@@ -986,11 +954,9 @@ def test_bump_command_prelease_version_type_check_old_tags(
986954 tag_exists = git .tag_exist ("v0.2.0-a0" )
987955 assert tag_exists is True
988956
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 ()
994960
995961 testargs = ["cz" , "bump" , "--prerelease" , "alpha" ]
996962 mocker .patch .object (sys , "argv" , testargs )
@@ -999,11 +965,9 @@ def test_bump_command_prelease_version_type_check_old_tags(
999965 tag_exists = git .tag_exist ("v0.2.0-a1" )
1000966 assert tag_exists is True
1001967
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 ()
1007971
1008972 # PRERELEASE BUMP CREATES VERSION WITHOUT PRERELEASE
1009973 testargs = ["cz" , "bump" ]
@@ -1013,8 +977,6 @@ def test_bump_command_prelease_version_type_check_old_tags(
1013977 tag_exists = git .tag_exist ("v0.2.0" )
1014978 assert tag_exists is True
1015979
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