@@ -69,54 +69,50 @@ def test_substitution_branch(repo, template, real_template, branch, suffix):
69
69
# leading zeros are removed by setuptools
70
70
("{tag}.post{env:PIPELINE_ID}" , "234" , "234" ),
71
71
("{tag}.post{env:PIPELINE_ID}" , "0234" , "234" ),
72
- ("{tag}.post{env:PIPELINE_ID}" , None , "UNKNOWN" ),
73
72
("{tag}.post{env:PIPELINE_ID:123}" , "234" , "234" ),
74
73
("{tag}.post{env:PIPELINE_ID:123}" , None , "123" ),
75
74
("{tag}.post{env:PIPELINE_ID:IGNORE}" , "234" , "234" ),
76
75
("{tag}.post{env:PIPELINE_ID:IGNORE}" , None , "0" ),
77
76
("{tag}.post{env:PIPELINE_ID:}" , "234" , "234" ),
78
- ("{tag}.post{env:PIPELINE_ID:}" , None , "UNKNOWN" ),
79
77
("{tag}.post{env:PIPELINE_ID:{ccount}}" , "234" , "234" ),
80
78
("{tag}.post{env:PIPELINE_ID:{ccount}}" , None , "1" ),
81
79
("{tag}.post{env:PIPELINE_ID:{timestamp:%Y}}" , "234" , "234" ),
82
80
("{tag}.post{env:PIPELINE_ID:{timestamp:%Y}}" , None , datetime .now ().year ),
83
81
("{tag}.post{env:PIPELINE_ID:{env:ANOTHER_ENV}}" , "234" , "234" ),
84
- ("{tag}.post{env:PIPELINE_ID:{env:ANOTHER_ENV}}" , None , "3.4.5 " ),
82
+ ("{tag}.post{env:PIPELINE_ID:{env:ANOTHER_ENV}}" , None , "345 " ),
85
83
("{tag}.post{env:PIPELINE_ID:{env:MISSING_ENV}}" , "234" , "234" ),
86
- ("{tag}.post{env:PIPELINE_ID:{env:MISSING_ENV}}" , None , "UNKNOWN" ),
87
84
("{tag}.post{env:PIPELINE_ID:{env:MISSING_ENV:IGNORE}}" , "234" , "234" ),
88
85
("{tag}.post{env:PIPELINE_ID:{env:MISSING_ENV:IGNORE}}" , None , "0" ),
89
86
("{tag}.post{env:PIPELINE_ID:{env:MISSING_ENV:}}" , "234" , "234" ),
90
- ("{tag}.post{env:PIPELINE_ID:{env:MISSING_ENV:}}" , None , "UNKNOWN" ),
91
- ("{tag}.post{env:PIPELINE_ID:{env:MISSING_ENV:5.6.7}}" , "234" , "234" ),
92
- ("{tag}.post{env:PIPELINE_ID:{env:MISSING_ENV:5.6.7}}" , None , "5.6.7" ),
87
+ ("{tag}.post{env:PIPELINE_ID:{env:MISSING_ENV:567}}" , "234" , "234" ),
88
+ ("{tag}.post{env:PIPELINE_ID:{env:MISSING_ENV:567}}" , None , "567" ),
93
89
("{tag}.post{env:PIPELINE_ID:{env:MISSING_ENV:{ccount}}}" , "234" , "234" ),
94
90
("{tag}.post{env:PIPELINE_ID:{env:MISSING_ENV:{ccount}}}" , None , "1" ),
95
91
("{tag}.post{env:PIPELINE_ID:{env:MISSING_ENV:{timestamp:%Y}}}" , "234" , "234" ),
96
92
("{tag}.post{env:PIPELINE_ID:{env:MISSING_ENV:{timestamp:%Y}}}" , None , datetime .now ().year ),
97
- ("{tag}.post{env:PIPELINE_ID}+abc{env:ANOTHER_ENV}" , "234" , "234+abc3.4.5 " ),
93
+ ("{tag}.post{env:PIPELINE_ID}+abc{env:ANOTHER_ENV}" , "234" , "234+abc345 " ),
98
94
("{tag}.post{env:PIPELINE_ID}+abc{env:MISSING_ENV}" , "234" , "234+abcunknown" ),
99
95
("{tag}.post{env:PIPELINE_ID}+abc{env:MISSING_ENV:5.6.7}" , "234" , "234+abc5.6.7" ),
100
- ("{tag}.post{env:PIPELINE_ID}+abc{env:MISSING_ENV:B-C% D}" , "234" , "234+abcb.c.d" ),
96
+ ("{tag}.post{env:PIPELINE_ID}+abc{env:MISSING_ENV:B-C- D}" , "234" , "234+abcb.c.d" ),
101
97
("{tag}.post{env:PIPELINE_ID}+abc{env:MISSING_ENV:IGNORE}d" , "234" , "234+abcd" ),
102
98
("{tag}.post{env:PIPELINE_ID}+abc{env:MISSING_ENV:}d" , "234" , "234+abcunknownd" ),
103
- ("{tag}.post{env:PIPELINE_ID}+abc{env:MISSING_ENV: }d" , "234" , "234+abc.d" ),
99
+ ("{tag}.post{env:PIPELINE_ID}+abc{env:MISSING_ENV:. }d" , "234" , "234+abc.d" ),
104
100
("{tag}.post{env:PIPELINE_ID}+abc{env:MISSING_ENV:{ccount}}" , "234" , "234+abc1" ),
105
101
(
106
102
"{tag}.post{env:PIPELINE_ID}+abc{env:MISSING_ENV:{timestamp:%Y}}" ,
107
103
"234" ,
108
104
"234+abc" + str (datetime .now ().year ),
109
105
),
110
106
# empty env variable name
111
- ("{tag}.post{env: } " , "234" , "UNKNOWN " ),
107
+ ("{tag}.post{env:PIPELINE_ID}+abc{env: }d " , "234" , "234+abcunknownd " ),
112
108
],
113
109
)
114
110
def test_substitution_env (repo , dev_template , pipeline_id , suffix ):
115
111
create_setup_py (repo , {"dev_template" : dev_template })
116
112
create_tag (repo , "1.2.3" )
117
113
create_file (repo )
118
114
119
- env = {"ANOTHER_ENV" : "3.4.5 " }
115
+ env = {"ANOTHER_ENV" : "345 " }
120
116
if pipeline_id is not None :
121
117
env ["PIPELINE_ID" ] = pipeline_id
122
118
@@ -139,8 +135,8 @@ def test_substitution_env(repo, dev_template, pipeline_id, suffix):
139
135
"{tag}.post{ccount}+{}" ,
140
136
lambda dt : (dt .strftime ("%Y.%m.%dt%H.%M" ),),
141
137
),
142
- # unknown format
143
- ("{tag}+git{timestamp:%i }" , "{tag}+git.i " , lambda x : []),
138
+ # pure string
139
+ ("{tag}+git. {timestamp:abc }" , "{tag}+git.abc " , lambda x : []),
144
140
],
145
141
)
146
142
def test_substitution_timestamp (repo , template , fmt , callback ):
@@ -155,6 +151,7 @@ def test_substitution_timestamp(repo, template, fmt, callback):
155
151
if new_value == value :
156
152
break
157
153
value = new_value
154
+
158
155
assert new_value in get_version_setup_py (repo )
159
156
160
157
@@ -170,6 +167,7 @@ def test_substitution_timestamp(repo, template, fmt, callback):
170
167
"{tag}+a{env:MISSING_ENV:{}}}" ,
171
168
"{tag}+a{timestamp:A:B}" ,
172
169
"{tag}+a{timestamp:{%Y}" ,
170
+ "{tag}+a{timestamp:%i}" ,
173
171
],
174
172
)
175
173
def test_substitution_wrong_format (repo , template ):
0 commit comments