Skip to content

Commit

Permalink
Fix for Python 4 (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk authored and etingof committed Aug 27, 2019
1 parent 41ce2e5 commit 7214dca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions tests/codec/ber/test_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,17 +486,17 @@ def testShortEncoding(self):
if sys.version_info[0:2] > (2, 5):
class UniversalStringDecoderTestCase(BaseTestCase):
def testDecoder(self):
assert decoder.decode(ints2octs((28, 12, 0, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99))) == (char.UniversalString(sys.version_info[0] == 3 and 'abc' or unicode('abc')), null)
assert decoder.decode(ints2octs((28, 12, 0, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99))) == (char.UniversalString(sys.version_info[0] >= 3 and 'abc' or unicode('abc')), null)


class BMPStringDecoderTestCase(BaseTestCase):
def testDecoder(self):
assert decoder.decode(ints2octs((30, 6, 0, 97, 0, 98, 0, 99))) == (char.BMPString(sys.version_info[0] == 3 and 'abc' or unicode('abc')), null)
assert decoder.decode(ints2octs((30, 6, 0, 97, 0, 98, 0, 99))) == (char.BMPString(sys.version_info[0] >= 3 and 'abc' or unicode('abc')), null)


class UTF8StringDecoderTestCase(BaseTestCase):
def testDecoder(self):
assert decoder.decode(ints2octs((12, 3, 97, 98, 99))) == (char.UTF8String(sys.version_info[0] == 3 and 'abc' or unicode('abc')), null)
assert decoder.decode(ints2octs((12, 3, 97, 98, 99))) == (char.UTF8String(sys.version_info[0] >= 3 and 'abc' or unicode('abc')), null)


class SequenceOfDecoderTestCase(BaseTestCase):
Expand Down
12 changes: 6 additions & 6 deletions tests/codec/ber/test_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,40 +436,40 @@ def testChar(self):
if sys.version_info[0:2] > (2, 5):
class UniversalStringEncoderTestCase(BaseTestCase):
def testEncoding(self):
assert encoder.encode(char.UniversalString(sys.version_info[0] == 3 and 'abc' or unicode('abc'))) == ints2octs(
assert encoder.encode(char.UniversalString(sys.version_info[0] >= 3 and 'abc' or unicode('abc'))) == ints2octs(
(28, 12, 0, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99)), 'Incorrect encoding'


class UniversalStringEncoderWithSchemaTestCase(BaseTestCase):
def testEncoding(self):
assert encoder.encode(
sys.version_info[0] == 3 and 'abc' or unicode('abc'), asn1Spec=char.UniversalString()
sys.version_info[0] >= 3 and 'abc' or unicode('abc'), asn1Spec=char.UniversalString()
) == ints2octs((28, 12, 0, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99)), 'Incorrect encoding'


class BMPStringEncoderTestCase(BaseTestCase):
def testEncoding(self):
assert encoder.encode(char.BMPString(sys.version_info[0] == 3 and 'abc' or unicode('abc'))) == ints2octs(
assert encoder.encode(char.BMPString(sys.version_info[0] >= 3 and 'abc' or unicode('abc'))) == ints2octs(
(30, 6, 0, 97, 0, 98, 0, 99)), 'Incorrect encoding'


class BMPStringEncoderWithSchemaTestCase(BaseTestCase):
def testEncoding(self):
assert encoder.encode(
sys.version_info[0] == 3 and 'abc' or unicode('abc'), asn1Spec=char.BMPString()
sys.version_info[0] >= 3 and 'abc' or unicode('abc'), asn1Spec=char.BMPString()
) == ints2octs((30, 6, 0, 97, 0, 98, 0, 99)), 'Incorrect encoding'


class UTF8StringEncoderTestCase(BaseTestCase):
def testEncoding(self):
assert encoder.encode(char.UTF8String(sys.version_info[0] == 3 and 'abc' or unicode('abc'))) == ints2octs(
assert encoder.encode(char.UTF8String(sys.version_info[0] >= 3 and 'abc' or unicode('abc'))) == ints2octs(
(12, 3, 97, 98, 99)), 'Incorrect encoding'


class UTF8StringEncoderWithSchemaTestCase(BaseTestCase):
def testEncoding(self):
assert encoder.encode(
sys.version_info[0] == 3 and 'abc' or unicode('abc'), asn1Spec=char.UTF8String()
sys.version_info[0] >= 3 and 'abc' or unicode('abc'), asn1Spec=char.UTF8String()
) == ints2octs((12, 3, 97, 98, 99)), 'Incorrect encoding'


Expand Down

0 comments on commit 7214dca

Please sign in to comment.