mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
python compat: reduce use of 'if PY3:'
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
This commit is contained in:
parent
4d9d63b000
commit
bcaf076d30
@ -23,7 +23,6 @@ import io
|
||||
|
||||
from io import BytesIO
|
||||
from xml.etree.ElementTree import Element, SubElement
|
||||
from samba.compat import PY3
|
||||
from samba.gp_parse import GPParser
|
||||
from samba.compat import text_type
|
||||
# [MS-GPAC] Group Policy Audit Configuration
|
||||
|
@ -25,7 +25,6 @@ from samba import credentials
|
||||
import samba.tests
|
||||
import os
|
||||
import binascii
|
||||
from samba.compat import PY3
|
||||
from samba.dcerpc import misc
|
||||
|
||||
|
||||
@ -34,13 +33,6 @@ class CredentialsTests(samba.tests.TestCaseInTempDir):
|
||||
def setUp(self):
|
||||
super(CredentialsTests, self).setUp()
|
||||
self.creds = credentials.Credentials()
|
||||
if PY3:
|
||||
# Because Python 2 does not support 'x' mode and Python 3
|
||||
# does not support 'wx' mode in open() function
|
||||
# for exclusive creation
|
||||
self.open_mode = 'x'
|
||||
else:
|
||||
self.open_mode = 'wx'
|
||||
|
||||
def test_set_username(self):
|
||||
self.creds.set_username("somebody")
|
||||
@ -203,7 +195,7 @@ class CredentialsTests(samba.tests.TestCaseInTempDir):
|
||||
username = "user"
|
||||
|
||||
passwd_file_name = os.path.join(self.tempdir, "parse_file")
|
||||
passwd_file_fd = open(passwd_file_name, self.open_mode)
|
||||
passwd_file_fd = open(passwd_file_name, 'x')
|
||||
passwd_file_fd.write("realm=%s\n" % realm)
|
||||
passwd_file_fd.write("domain=%s\n" % domain)
|
||||
passwd_file_fd.write("username=%s\n" % username)
|
||||
@ -226,7 +218,7 @@ class CredentialsTests(samba.tests.TestCaseInTempDir):
|
||||
username = "user"
|
||||
|
||||
passwd_file_name = os.path.join(self.tempdir, "parse_file")
|
||||
passwd_file_fd = open(passwd_file_name, self.open_mode)
|
||||
passwd_file_fd = open(passwd_file_name, 'x')
|
||||
passwd_file_fd.write("realm=%s\n" % realm)
|
||||
passwd_file_fd.write("domain=%s\n" % domain)
|
||||
passwd_file_fd.write("username=%s\\%s\n" % (domain, username))
|
||||
@ -251,7 +243,7 @@ class CredentialsTests(samba.tests.TestCaseInTempDir):
|
||||
userdom = "userdom"
|
||||
|
||||
passwd_file_name = os.path.join(self.tempdir, "parse_file")
|
||||
passwd_file_fd = open(passwd_file_name, self.open_mode)
|
||||
passwd_file_fd = open(passwd_file_name, 'x')
|
||||
passwd_file_fd.write("realm=%s\n" % realm)
|
||||
passwd_file_fd.write("domain=%s\n" % domain)
|
||||
passwd_file_fd.write("username=%s/%s\n" % (userdom, username))
|
||||
@ -274,7 +266,7 @@ class CredentialsTests(samba.tests.TestCaseInTempDir):
|
||||
userdom = "userdom"
|
||||
|
||||
passwd_file_name = os.path.join(self.tempdir, "parse_file")
|
||||
passwd_file_fd = open(passwd_file_name, self.open_mode)
|
||||
passwd_file_fd = open(passwd_file_name, 'x')
|
||||
passwd_file_fd.write("username=%s\\%s%%%s\n" % (userdom, username, password))
|
||||
passwd_file_fd.write("realm=ignorerealm\n")
|
||||
passwd_file_fd.write("domain=ignoredomain\n")
|
||||
@ -297,7 +289,7 @@ class CredentialsTests(samba.tests.TestCaseInTempDir):
|
||||
userdom = "userdom"
|
||||
|
||||
passwd_file_name = os.path.join(self.tempdir, "parse_file")
|
||||
passwd_file_fd = open(passwd_file_name, self.open_mode)
|
||||
passwd_file_fd = open(passwd_file_name, 'x')
|
||||
passwd_file_fd.write("realm=ignorerealm\n")
|
||||
passwd_file_fd.write("username=%s\\%s%%%s\n" % (userdom, username, password))
|
||||
passwd_file_fd.write("domain=ignoredomain\n")
|
||||
|
Loading…
Reference in New Issue
Block a user