mirror of
https://github.com/actions/setup-python
synced 2025-04-05 06:49:43 +00:00
Improve workflows (#88)
* Improve workflows * Update workflows * Small fix
This commit is contained in:
22
__tests__/verify-python.py
Normal file
22
__tests__/verify-python.py
Normal file
@ -0,0 +1,22 @@
|
||||
import sys
|
||||
argCount = len(sys.argv) - 1
|
||||
|
||||
if argCount == 1:
|
||||
expectedVersion = sys.argv[1]
|
||||
versions = len(expectedVersion.split("."))
|
||||
majorMinor = str(sys.version_info[0]) + '.' + str(sys.version_info[1])
|
||||
|
||||
if versions == 2:
|
||||
# Test only major and minor version
|
||||
if expectedVersion != majorMinor:
|
||||
raise Exception("Incorrect major + minor version detected\nExpected: " + expectedVersion + "\nActual: " + majorMinor)
|
||||
elif versions == 3:
|
||||
# Test major, minor and micro version
|
||||
majorMinorMicro = majorMinor + '.' + str(sys.version_info[2])
|
||||
if expectedVersion != majorMinorMicro:
|
||||
raise Exception("Incorrect major + minor + micro version detected\nExpected: " + expectedVersion + "\nActual: " + majorMinorMicro)
|
||||
else:
|
||||
raise Exception("Incorrect number of arguments supplied")
|
||||
print("Correct version of Python " + expectedVersion + " detected")
|
||||
else:
|
||||
raise Exception("Incorrect number of arguments supplied")
|
Reference in New Issue
Block a user