fork/mons
git clone https://git.julia.blue/fork/mons
a96812a
fixes
1import operator as op 2 3import pytest 4 5from mons .version import NOVERSION 6from mons .version import Version 7 8 9@ pytest . mark . parametrize ( 10( "version" , "expect" ), 11[ 12pytest . param ( None , None , id = "None = None" ), 13pytest . param ( "NoVersion" , NOVERSION(), id = '"NoVersion" = NOVERSION' ), 14pytest . param ( "1.2.3.4" , Version( 1 , 2 , 3 , 4 ), id = '"1.2.3.4" = 1.2.3.4' ), 15pytest . param ( 16"1.2.3-pre" , Version( 1 , 2 , 3 , Tag = "pre" ), id = '"1.2.3-pre" = 1.2.3-pre' 17), 18pytest . param ( 19"1.2.3+meta" , Version( 1 , 2 , 3 , Tag = "meta" ), id = '"1.2.3+meta" = 1.2.3+meta' 20), 21], 22) 23def test_version_parse (version ,expect ): 24assert str (Version .parse (version ))== str (expect ) 25 26 27@ pytest . mark . parametrize ( 28( "version" , "required" ), 29[ 30pytest . param (Version( 1 , 2 , 3 , 4 ), Version( 1 , 2 , 3 , 4 ), id = "equal" ), 31pytest . param (Version( 2 , 2 ), Version( 2 , 1 ), id = "minor" ), 32pytest . param (Version( 1 , 2 , 3 , 1 ), Version( 1 , 2 , 3 , 0 ), id = "revision" ), 33pytest . param (Version( 0 , 0 ), Version( 5 , 1 ), id = "0.0.0" ), 34], 35) 36def test_version_satisfies (version ,required ): 37assert version .satisfies (required ) 38 39 40@ pytest . mark . parametrize ( 41( "version" , "required" ), 42[ 43pytest . param (Version( 1 , 1 , 1 , 0 ), Version( 1 , 1 , 1 , 1 ), id = "revision" ), 44pytest . param (Version( 1 , 2 , 3 , 4 ), Version( 1 , 3 , 2 , 4 ), id = "minor" ), 45pytest . param (Version( 1 , 0 ), Version( 2 , 0 ), id = "major" ), 46], 47) 48def test_version_satisfies_fail (version ,required ): 49assert not version .satisfies (required ) 50 51 52@ pytest . mark . parametrize ( 53( "left" , "right" , "comparison" ), 54[ 55(Version( 1 , 2 , 3 , 4 ), Version( 1 , 2 , 3 , 4 ), op . eq ), 56(Version( 1 , 2 , 3 , 4 ), Version( 1 , 0 , 0 , 0 ), op . ne ), 57(Version( 1 , 2 , 3 , 4 ), Version( 1 , 2 , 3 , 3 ), op . gt ), 58(Version( 1 , 2 , 3 , 4 ), Version( 1 , 3 , 3 , 4 ), op . lt ), 59], 60) 61def test_version_compare (left ,right ,comparison ): 62assert comparison (left ,right )