Allow len(Version) to return number of split components. (#7918)
This commit is contained in:
parent
310addea91
commit
6cc79f8142
2 changed files with 11 additions and 0 deletions
|
@ -488,6 +488,14 @@ def check_repr_and_str(vrs):
|
||||||
check_repr_and_str('R2016a.2-3_4')
|
check_repr_and_str('R2016a.2-3_4')
|
||||||
|
|
||||||
|
|
||||||
|
def test_len():
|
||||||
|
a = Version('1.2.3.4')
|
||||||
|
assert len(a) == len(a.version)
|
||||||
|
assert(len(a) == 4)
|
||||||
|
b = Version('2018.0')
|
||||||
|
assert(len(b) == 2)
|
||||||
|
|
||||||
|
|
||||||
def test_get_item():
|
def test_get_item():
|
||||||
a = Version('0.1_2-3')
|
a = Version('0.1_2-3')
|
||||||
assert isinstance(a[1], int)
|
assert isinstance(a[1], int)
|
||||||
|
|
|
@ -253,6 +253,9 @@ def satisfies(self, other):
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return iter(self.version)
|
return iter(self.version)
|
||||||
|
|
||||||
|
def __len__(self):
|
||||||
|
return len(self.version)
|
||||||
|
|
||||||
def __getitem__(self, idx):
|
def __getitem__(self, idx):
|
||||||
cls = type(self)
|
cls = type(self)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue