Skip to content

Commit ae5b10f

Browse files
committed
style(Tests/t_ldap_dn): use raw strings instead of escape sequences
1 parent 3411d7c commit ae5b10f

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

Tests/t_ldap_dn.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ def test_escape_dn_chars(self):
4040
test function escape_dn_chars()
4141
"""
4242
self.assertEqual(ldap.dn.escape_dn_chars('foobar'), 'foobar')
43-
self.assertEqual(ldap.dn.escape_dn_chars('foo,bar'), 'foo\\,bar')
44-
self.assertEqual(ldap.dn.escape_dn_chars('foo=bar'), 'foo\\=bar')
43+
self.assertEqual(ldap.dn.escape_dn_chars('foo,bar'), r'foo\,bar')
44+
self.assertEqual(ldap.dn.escape_dn_chars('foo=bar'), r'foo\=bar')
4545
self.assertEqual(ldap.dn.escape_dn_chars('foo#bar'), 'foo#bar')
46-
self.assertEqual(ldap.dn.escape_dn_chars('#foobar'), '\\#foobar')
46+
self.assertEqual(ldap.dn.escape_dn_chars('#foobar'), r'\#foobar')
4747
self.assertEqual(ldap.dn.escape_dn_chars('foo bar'), 'foo bar')
48-
self.assertEqual(ldap.dn.escape_dn_chars(' foobar'), '\\ foobar')
49-
self.assertEqual(ldap.dn.escape_dn_chars(' '), '\\ ')
50-
self.assertEqual(ldap.dn.escape_dn_chars(' '), '\\ \\ ')
51-
self.assertEqual(ldap.dn.escape_dn_chars('foobar '), 'foobar\\ ')
52-
self.assertEqual(ldap.dn.escape_dn_chars('f+o>o,b<a;r="\00"'), 'f\\+o\\>o\\,b\\<a\\;r\\=\\"\\\x00\\"')
53-
self.assertEqual(ldap.dn.escape_dn_chars('foo\\,bar'), 'foo\\\\\\,bar')
48+
self.assertEqual(ldap.dn.escape_dn_chars(' foobar'), r'\ foobar')
49+
self.assertEqual(ldap.dn.escape_dn_chars(' '), r'\ ')
50+
self.assertEqual(ldap.dn.escape_dn_chars(' '), r'\ \ ')
51+
self.assertEqual(ldap.dn.escape_dn_chars('foobar '), r'foobar\ ')
52+
self.assertEqual(ldap.dn.escape_dn_chars('f+o>o,b<a;r="\00"'), r'f\+o\>o\,b\<a\;r\=\"\\x00\"')
53+
self.assertEqual(ldap.dn.escape_dn_chars(r'foo\,bar'), r'foo\\\,bar')
5454

5555
def test_str2dn(self):
5656
"""
@@ -95,7 +95,7 @@ def test_str2dn(self):
9595
]
9696
)
9797
self.assertEqual(
98-
ldap.dn.str2dn('uid=test\\, 42,ou=Testing,dc=example,dc=com', flags=0),
98+
ldap.dn.str2dn(r'uid=test\, 42,ou=Testing,dc=example,dc=com', flags=0),
9999
[
100100
[('uid', 'test, 42', 1)],
101101
[('ou', 'Testing', 1)],
@@ -112,7 +112,7 @@ def test_str2dn(self):
112112
]
113113
)
114114
self.assertEqual(
115-
ldap.dn.str2dn('cn=\\c3\\a4\\c3\\b6\\c3\\bc\\c3\\84\\c3\\96\\c3\\9c\\c3\\9f,dc=example,dc=com', flags=0),
115+
ldap.dn.str2dn(r'cn=\c3\a4\c3\b6\c3\bc\c3\84\c3\96\c3\9c\c3\9f,dc=example,dc=com', flags=0),
116116
[
117117
[('cn', 'äöüÄÖÜß', ldap.AVA_NONPRINTABLE)],
118118
[('dc', 'example', 1)],
@@ -168,7 +168,7 @@ def test_dn2str(self):
168168
[('dc', 'example', 1)],
169169
[('dc', 'com', 1)]
170170
]),
171-
'uid=test\\, 42,ou=Testing,dc=example,dc=com'
171+
r'uid=test\, 42,ou=Testing,dc=example,dc=com'
172172
)
173173
self.assertEqual(
174174
ldap.dn.dn2str([
@@ -323,15 +323,15 @@ def test_explode_dn(self):
323323
['test42', 'Testing', 'example', 'com']
324324
)
325325
self.assertEqual(
326-
ldap.dn.explode_dn('uid=test\\, 42,ou=Testing,dc=example,dc=com', flags=0),
327-
['uid=test\\, 42', 'ou=Testing', 'dc=example', 'dc=com']
326+
ldap.dn.explode_dn(r'uid=test\, 42,ou=Testing,dc=example,dc=com', flags=0),
327+
[r'uid=test\, 42', 'ou=Testing', 'dc=example', 'dc=com']
328328
)
329329
self.assertEqual(
330330
ldap.dn.explode_dn('cn=äöüÄÖÜß,dc=example,dc=com', flags=0),
331331
['cn=äöüÄÖÜß', 'dc=example', 'dc=com']
332332
)
333333
self.assertEqual(
334-
ldap.dn.explode_dn('cn=\\c3\\a4\\c3\\b6\\c3\\bc\\c3\\84\\c3\\96\\c3\\9c\\c3\\9f,dc=example,dc=com', flags=0),
334+
ldap.dn.explode_dn(r'cn=\c3\a4\c3\b6\c3\bc\c3\84\c3\96\c3\9c\c3\9f,dc=example,dc=com', flags=0),
335335
['cn=äöüÄÖÜß', 'dc=example', 'dc=com']
336336
)
337337

@@ -365,15 +365,15 @@ def test_explode_rdn(self):
365365
['test42']
366366
)
367367
self.assertEqual(
368-
ldap.dn.explode_rdn('uid=test\\+ 42', flags=0),
369-
['uid=test\\+ 42']
368+
ldap.dn.explode_rdn(r'uid=test\+ 42', flags=0),
369+
[r'uid=test\+ 42']
370370
)
371371
self.assertEqual(
372372
ldap.dn.explode_rdn('cn=äöüÄÖÜß', flags=0),
373373
['cn=äöüÄÖÜß']
374374
)
375375
self.assertEqual(
376-
ldap.dn.explode_rdn('cn=\\c3\\a4\\c3\\b6\\c3\\bc\\c3\\84\\c3\\96\\c3\\9c\\c3\\9f', flags=0),
376+
ldap.dn.explode_rdn(r'cn=\c3\a4\c3\b6\c3\bc\c3\84\c3\96\c3\9c\c3\9f', flags=0),
377377
['cn=äöüÄÖÜß']
378378
)
379379

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy