@@ -341,18 +341,18 @@ class TestValidatePythonVersion:
341
341
def test_it_defaults_to_a_valid_version (self ):
342
342
build = get_build_config ({'python' : {}})
343
343
build .validate ()
344
- assert build .python .version == 2
344
+ assert build .python .version == '2'
345
345
assert build .python_interpreter == 'python2.7'
346
- assert build .python_full_version == 2.7
346
+ assert build .python_full_version == ' 2.7'
347
347
348
348
def test_it_supports_other_versions (self ):
349
349
build = get_build_config (
350
350
{'python' : {'version' : 3.7 }},
351
351
)
352
352
build .validate ()
353
- assert build .python .version == 3.7
353
+ assert build .python .version == ' 3.7'
354
354
assert build .python_interpreter == 'python3.7'
355
- assert build .python_full_version == 3.7
355
+ assert build .python_full_version == ' 3.7'
356
356
357
357
def test_it_supports_string_versions (self ):
358
358
build = get_build_config (
@@ -383,9 +383,9 @@ def test_it_validates_wrong_type(self):
383
383
384
384
def test_it_validates_env_supported_versions (self ):
385
385
build = get_build_config (
386
- {'python' : {'version' : 3.6 }},
386
+ {'python' : {'version' : ' 3.6' }},
387
387
env_config = {
388
- 'python' : {'supported_versions' : [3.5 ]},
388
+ 'python' : {'supported_versions' : [' 3.5' ]},
389
389
'build' : {'image' : 'custom' },
390
390
},
391
391
)
@@ -395,18 +395,18 @@ def test_it_validates_env_supported_versions(self):
395
395
assert excinfo .value .code == INVALID_CHOICE
396
396
397
397
build = get_build_config (
398
- {'python' : {'version' : 3.6 }},
398
+ {'python' : {'version' : ' 3.6' }},
399
399
env_config = {
400
- 'python' : {'supported_versions' : [3.5 , 3.6 ]},
400
+ 'python' : {'supported_versions' : [' 3.5' , ' 3.6' ]},
401
401
'build' : {'image' : 'custom' },
402
402
},
403
403
)
404
404
build .validate ()
405
- assert build .python .version == 3.6
405
+ assert build .python .version == ' 3.6'
406
406
assert build .python_interpreter == 'python3.6'
407
- assert build .python_full_version == 3.6
407
+ assert build .python_full_version == ' 3.6'
408
408
409
- @pytest .mark .parametrize ('value' , [2 , 3 ])
409
+ @pytest .mark .parametrize ('value' , ['2' , '3' ])
410
410
def test_it_respects_default_value (self , value ):
411
411
defaults = {
412
412
'python_version' : value ,
@@ -724,7 +724,7 @@ def test_as_dict(tmpdir):
724
724
'version' : '1' ,
725
725
'formats' : ['pdf' ],
726
726
'python' : {
727
- 'version' : 3.7 ,
727
+ 'version' : ' 3.7' ,
728
728
'install' : [{
729
729
'requirements' : 'requirements.txt' ,
730
730
}],
@@ -986,8 +986,8 @@ def test_python_check_invalid_types(self, value):
986
986
@pytest .mark .parametrize (
987
987
'image,versions' ,
988
988
[
989
- ('latest' , [2 , 2.7 , 3 , 3.5 , 3.6 , 3.7 , 'pypy3.5' ]),
990
- ('stable' , [2 , 2.7 , 3 , 3.5 , 3.6 , 3.7 ]),
989
+ ('latest' , ['2' , ' 2.7' , '3' , ' 3.5' , ' 3.6' , ' 3.7' , 'pypy3.5' ]),
990
+ ('stable' , ['2' , ' 2.7' , '3' , ' 3.5' , ' 3.6' , ' 3.7' ]),
991
991
],
992
992
)
993
993
def test_python_version (self , image , versions ):
@@ -1015,13 +1015,25 @@ def test_python_version_accepts_string(self):
1015
1015
build .validate ()
1016
1016
assert build .python .version == '3.6'
1017
1017
1018
- def test_python_version_310 (self ):
1018
+ def test_python_version_accepts_number (self ):
1019
+ build = self .get_build_config ({
1020
+ 'build' : {
1021
+ 'image' : 'latest' ,
1022
+ },
1023
+ 'python' : {
1024
+ 'version' : 3.6 ,
1025
+ },
1026
+ })
1027
+ build .validate ()
1028
+ assert build .python .version == '3.6'
1029
+
1030
+ def test_python_version_310_as_number (self ):
1019
1031
build = self .get_build_config ({
1020
1032
'build' : {
1021
1033
'image' : 'testing' ,
1022
1034
},
1023
1035
'python' : {
1024
- 'version' : ' 3.10' ,
1036
+ 'version' : 3.10 ,
1025
1037
},
1026
1038
})
1027
1039
build .validate ()
@@ -1051,27 +1063,27 @@ def test_python_version_invalid(self, image, versions):
1051
1063
def test_python_version_default (self ):
1052
1064
build = self .get_build_config ({})
1053
1065
build .validate ()
1054
- assert build .python .version == 3
1066
+ assert build .python .version == '3'
1055
1067
1056
1068
@pytest .mark .parametrize (
1057
- 'image,default_version' ,
1069
+ 'image, default_version, full_version ' ,
1058
1070
[
1059
- ('2.0' , 3.5 ),
1060
- ('4.0' , 3.7 ),
1061
- ('5.0' , 3.7 ),
1062
- ('latest' , 3.7 ),
1063
- ('stable' , 3.7 ),
1071
+ ('2.0' , '3' , '3.5' ),
1072
+ ('4.0' , '3' , '3.7' ),
1073
+ ('5.0' , '3' , '3.7' ),
1074
+ ('latest' , '3' , '3.7' ),
1075
+ ('stable' , '3' , '3.7' ),
1064
1076
],
1065
1077
)
1066
- def test_python_version_default_from_image (self , image , default_version ):
1078
+ def test_python_version_default_from_image (self , image , default_version , full_version ):
1067
1079
build = self .get_build_config ({
1068
1080
'build' : {
1069
1081
'image' : image ,
1070
1082
},
1071
1083
})
1072
1084
build .validate ()
1073
- assert build .python .version == int ( default_version ) # 2 or 3
1074
- assert build .python_full_version == default_version
1085
+ assert build .python .version == default_version
1086
+ assert build .python_full_version == full_version
1075
1087
1076
1088
@pytest .mark .parametrize ('value' , [2 , 3 ])
1077
1089
def test_python_version_overrides_default (self , value ):
@@ -1080,13 +1092,13 @@ def test_python_version_overrides_default(self, value):
1080
1092
{'defaults' : {'python_version' : value }},
1081
1093
)
1082
1094
build .validate ()
1083
- assert build .python .version == 3
1095
+ assert build .python .version == '3'
1084
1096
1085
- @pytest .mark .parametrize ('value' , [2 , 3 , 3.6 ])
1097
+ @pytest .mark .parametrize ('value' , ['2' , '3' , ' 3.6' ])
1086
1098
def test_python_version_priority_over_default (self , value ):
1087
1099
build = self .get_build_config (
1088
1100
{'python' : {'version' : value }},
1089
- {'defaults' : {'python_version' : 3 }},
1101
+ {'defaults' : {'python_version' : '3' }},
1090
1102
)
1091
1103
build .validate ()
1092
1104
assert build .python .version == value
@@ -2104,7 +2116,7 @@ def test_as_dict(self, tmpdir):
2104
2116
'version' : 2 ,
2105
2117
'formats' : ['pdf' ],
2106
2118
'python' : {
2107
- 'version' : 3.6 ,
2119
+ 'version' : ' 3.6' ,
2108
2120
'install' : [{
2109
2121
'requirements' : 'requirements.txt' ,
2110
2122
}],
@@ -2117,7 +2129,7 @@ def test_as_dict(self, tmpdir):
2117
2129
'version' : '2' ,
2118
2130
'formats' : ['pdf' ],
2119
2131
'python' : {
2120
- 'version' : 3.6 ,
2132
+ 'version' : ' 3.6' ,
2121
2133
'install' : [{
2122
2134
'requirements' : 'requirements.txt' ,
2123
2135
}],
0 commit comments