summaryrefslogtreecommitdiff
path: root/tests/type
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2019-07-12 22:31:41 +0200
committerGitHub <noreply@github.com>2019-07-12 22:31:41 +0200
commit7b3f79cac2ce765537baa406762d59eae47de04c (patch)
tree6942818a0fb1266825e93ce8b9f4aaf594b881f9 /tests/type
parentcf9b3f5f67501b85296c05456bbd324352177718 (diff)
downloadpyasn1-git-7b3f79cac2ce765537baa406762d59eae47de04c.tar.gz
Add `SequenceOf`/`SetOf` list-like slicing support (#168)
Diffstat (limited to 'tests/type')
-rw-r--r--tests/type/test_univ.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/type/test_univ.py b/tests/type/test_univ.py
index 169b73e..de7cdee 100644
--- a/tests/type/test_univ.py
+++ b/tests/type/test_univ.py
@@ -1090,6 +1090,13 @@ class SequenceOf(BaseTestCase):
# this is a deviation from standard sequence protocol
assert not s[2]
+ def testGetItemSlice(self):
+ s = self.s1.clone()
+ s.extend(['xxx', 'yyy', 'zzz'])
+ assert s[:1] == [str2octs('xxx')]
+ assert s[-2:] == [str2octs('yyy'), str2octs('zzz')]
+ assert s[1:2] == [str2octs('yyy')]
+
def testSetItem(self):
s = self.s1.clone()
s.append('xxx')
@@ -1097,6 +1104,16 @@ class SequenceOf(BaseTestCase):
assert len(s) == 3
assert s[1] == str2octs('')
+ def testSetItemSlice(self):
+ s = self.s1.clone()
+ s[:1] = ['xxx']
+ assert s == [str2octs('xxx')]
+ s[-2:] = ['yyy', 'zzz']
+ assert s == [str2octs('yyy'), str2octs('zzz')]
+ s[1:2] = ['yyy']
+ assert s == [str2octs('yyy'), str2octs('yyy')]
+ assert len(s) == 2
+
def testAppend(self):
self.s1.clear()
self.s1.setComponentByPosition(0, univ.OctetString('abc'))