summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2010-06-19 18:58:18 +0200
committerJelmer Vernooij <jelmer@samba.org>2010-06-19 22:46:45 +0200
commitc92db7b6dc31756fc461ea9f74e1cd675e3e160d (patch)
tree14a1cb47c782b42ab023e1e462447ee55ddeb179
parent105ebb34405eb458c51ebbfb57b3ce31a41c34e2 (diff)
downloadsamba-c92db7b6dc31756fc461ea9f74e1cd675e3e160d.tar.gz
samba-c92db7b6dc31756fc461ea9f74e1cd675e3e160d.tar.bz2
samba-c92db7b6dc31756fc461ea9f74e1cd675e3e160d.zip
python: Use samba.tests.TestCase, make sure base class tearDown and
setUp methods are called, fix formatting.
-rw-r--r--source4/auth/credentials/tests/bindings.py6
-rw-r--r--source4/auth/gensec/tests/bindings.py8
-rw-r--r--source4/auth/tests/bindings.py5
-rwxr-xr-xsource4/lib/ldb/tests/python/api.py5
-rwxr-xr-xsource4/lib/ldb/tests/python/ldap.py4
-rwxr-xr-xsource4/lib/ldb/tests/python/ldap_schema.py5
-rwxr-xr-xsource4/lib/ldb/tests/python/passwords.py3
-rwxr-xr-xsource4/lib/ldb/tests/python/sec_descriptor.py24
-rwxr-xr-xsource4/lib/ldb/tests/python/urgent_replication.py4
-rw-r--r--source4/lib/messaging/tests/bindings.py3
-rw-r--r--source4/lib/registry/tests/bindings.py9
-rw-r--r--source4/libcli/security/tests/bindings.py28
-rw-r--r--source4/param/tests/bindings.py5
-rw-r--r--source4/scripting/python/samba/tests/__init__.py17
-rw-r--r--source4/scripting/python/samba/tests/dcerpc/__init__.py2
-rw-r--r--source4/scripting/python/samba/tests/dcerpc/bare.py19
-rw-r--r--source4/scripting/python/samba/tests/dcerpc/misc.py6
-rw-r--r--source4/scripting/python/samba/tests/dcerpc/registry.py1
-rw-r--r--source4/scripting/python/samba/tests/dcerpc/rpcecho.py6
-rw-r--r--source4/scripting/python/samba/tests/dcerpc/sam.py1
-rw-r--r--source4/scripting/python/samba/tests/dcerpc/unix.py1
-rw-r--r--source4/scripting/python/samba/tests/netcmd.py5
-rw-r--r--source4/scripting/python/samba/tests/provision.py6
-rw-r--r--source4/scripting/python/samba/tests/samba3.py5
-rw-r--r--source4/scripting/python/samba/tests/shares.py2
-rw-r--r--source4/scripting/python/samba/tests/upgrade.py1
-rw-r--r--source4/scripting/python/samba/tests/xattr.py2
-rw-r--r--source4/torture/libnet/python/samr-test.py4
28 files changed, 107 insertions, 80 deletions
diff --git a/source4/auth/credentials/tests/bindings.py b/source4/auth/credentials/tests/bindings.py
index 30120b3a60..4cb059ddf0 100644
--- a/source4/auth/credentials/tests/bindings.py
+++ b/source4/auth/credentials/tests/bindings.py
@@ -23,11 +23,13 @@ Note that this just tests the bindings work. It does not intend to test
the functionality, that's already done in other tests.
"""
-import unittest
from samba import credentials
+import samba.tests
+
+class CredentialsTests(samba.tests.TestCase):
-class CredentialsTests(unittest.TestCase):
def setUp(self):
+ super(CredentialsTests, self).setUp()
self.creds = credentials.Credentials()
def test_set_username(self):
diff --git a/source4/auth/gensec/tests/bindings.py b/source4/auth/gensec/tests/bindings.py
index b9d80e4f9e..cffcc27aec 100644
--- a/source4/auth/gensec/tests/bindings.py
+++ b/source4/auth/gensec/tests/bindings.py
@@ -23,16 +23,16 @@ Note that this just tests the bindings work. It does not intend to test
the functionality, that's already done in other tests.
"""
-import unittest
from samba import gensec
-from samba.tests import env_loadparm
+import samba.tests
-class CredentialsTests(unittest.TestCase):
+class CredentialsTests(samba.tests.TestCase):
def setUp(self):
+ super(CredentialsTests, self).setUp()
settings = {}
settings["target_hostname"] = "localhost"
- settings["lp_ctx"] = env_loadparm()
+ settings["lp_ctx"] = samba.tests.env_loadparm()
self.gensec = gensec.Security.start_client(settings)
def test_info(self):
diff --git a/source4/auth/tests/bindings.py b/source4/auth/tests/bindings.py
index 15368a4bf7..58b66d3c98 100644
--- a/source4/auth/tests/bindings.py
+++ b/source4/auth/tests/bindings.py
@@ -23,10 +23,11 @@ Note that this just tests the bindings work. It does not intend to test
the functionality, that's already done in other tests.
"""
-import unittest
from samba import auth
+import samba.tests
+
+class AuthTests(samba.tests.TestCase):
-class AuthTests(unittest.TestCase):
def test_system_session(self):
auth.system_session()
diff --git a/source4/lib/ldb/tests/python/api.py b/source4/lib/ldb/tests/python/api.py
index 6303f6b6cb..4b4415afb1 100755
--- a/source4/lib/ldb/tests/python/api.py
+++ b/source4/lib/ldb/tests/python/api.py
@@ -2,12 +2,9 @@
# Simple tests for the ldb python bindings.
# Copyright (C) 2007 Jelmer Vernooij <jelmer@samba.org>
-import os, sys
+import os
import unittest
-# Required for the standalone LDB build
-sys.path.append("build/lib.linux-i686-2.4")
-
import ldb
def filename():
diff --git a/source4/lib/ldb/tests/python/ldap.py b/source4/lib/ldb/tests/python/ldap.py
index db1a47ce64..98ff628dfe 100755
--- a/source4/lib/ldb/tests/python/ldap.py
+++ b/source4/lib/ldb/tests/python/ldap.py
@@ -81,6 +81,7 @@ class BasicTests(unittest.TestCase):
return ndr_unpack( security.dom_sid,res[0]["objectSid"][0])
def setUp(self):
+ super(BasicTests, self).setUp()
self.ldb = ldb
self.gc_ldb = gc_ldb
self.base_dn = self.find_basedn(ldb)
@@ -2569,8 +2570,11 @@ nTSecurityDescriptor:: """ + desc_base64
finally:
self.delete_force(self.ldb, user_dn)
+
class BaseDnTests(unittest.TestCase):
+
def setUp(self):
+ super(BaseDnTests, self).setUp()
self.ldb = ldb
def test_rootdse_attrs(self):
diff --git a/source4/lib/ldb/tests/python/ldap_schema.py b/source4/lib/ldb/tests/python/ldap_schema.py
index ceebe11187..8e6865a4d2 100755
--- a/source4/lib/ldb/tests/python/ldap_schema.py
+++ b/source4/lib/ldb/tests/python/ldap_schema.py
@@ -45,6 +45,7 @@ creds = credopts.get_credentials(lp)
class SchemaTests(unittest.TestCase):
+
def delete_force(self, ldb, dn):
try:
ldb.delete(dn)
@@ -63,6 +64,7 @@ class SchemaTests(unittest.TestCase):
return res[0]["defaultNamingContext"][0]
def setUp(self):
+ super(SchemaTests, self).setUp()
self.ldb = ldb
self.schema_dn = self.find_schemadn(ldb)
self.base_dn = self.find_basedn(ldb)
@@ -214,6 +216,7 @@ name: """ + object_name + """
class SchemaTests_msDS_IntId(unittest.TestCase):
def setUp(self):
+ super(SchemaTests_msDS_IntId, self).setUp()
self.ldb = ldb
res = ldb.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"])
self.assertEquals(len(res), 1)
@@ -481,9 +484,11 @@ systemOnly: FALSE
else:
self.assertTrue("msDS-IntId" not in ldb_msg)
+
class SchemaTests_msDS_isRODC(unittest.TestCase):
def setUp(self):
+ super(SchemaTests_msDS_isRODC, self).setUp()
self.ldb = ldb
res = ldb.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"])
self.assertEquals(len(res), 1)
diff --git a/source4/lib/ldb/tests/python/passwords.py b/source4/lib/ldb/tests/python/passwords.py
index b3e6fc949e..dd5a1ca126 100755
--- a/source4/lib/ldb/tests/python/passwords.py
+++ b/source4/lib/ldb/tests/python/passwords.py
@@ -12,7 +12,6 @@
import optparse
import sys
-import time
import base64
import os
@@ -75,6 +74,7 @@ class PasswordTests(samba.tests.TestCase):
return res[0]["defaultNamingContext"][0]
def setUp(self):
+ super(PasswordTests, self).setUp()
self.ldb = ldb
self.base_dn = self.find_basedn(ldb)
@@ -558,6 +558,7 @@ userPassword: thatsAcomplPASS4
"userPassword": ["thatsAcomplPASS1", "thatsAcomplPASS1"] })
def tearDown(self):
+ super(PasswordTests, self).tearDown()
self.delete_force(self.ldb, "cn=testuser,cn=users," + self.base_dn)
self.delete_force(self.ldb, "cn=testuser2,cn=users," + self.base_dn)
# Close the second LDB connection (with the user credentials)
diff --git a/source4/lib/ldb/tests/python/sec_descriptor.py b/source4/lib/ldb/tests/python/sec_descriptor.py
index 43437fa186..91f607714e 100755
--- a/source4/lib/ldb/tests/python/sec_descriptor.py
+++ b/source4/lib/ldb/tests/python/sec_descriptor.py
@@ -19,7 +19,6 @@ from ldb import SCOPE_SUBTREE, SCOPE_BASE, LdbError, ERR_NO_SUCH_OBJECT
from samba.ndr import ndr_pack, ndr_unpack
from samba.dcerpc import security
-from samba import Ldb
from samba import gensec
from samba.samdb import SamDB
from samba.credentials import Credentials
@@ -28,6 +27,7 @@ from samba.dsdb import DS_DOMAIN_FUNCTION_2008
from samba.dcerpc.security import (
SECINFO_OWNER, SECINFO_GROUP, SECINFO_DACL, SECINFO_SACL)
from subunit.run import SubunitTestRunner
+import samba.tests
import unittest
parser = optparse.OptionParser("sec_descriptor [options] <host>")
@@ -54,7 +54,7 @@ creds.set_gensec_features(creds.get_gensec_features() | gensec.FEATURE_SEAL)
# Tests start here
#
-class DescriptorTests(unittest.TestCase):
+class DescriptorTests(samba.tests.TestCase):
def delete_force(self, ldb, dn):
try:
@@ -271,6 +271,7 @@ member: """ + self.get_users_domain_dn(username)
self.ldb_admin.enable_account("(sAMAccountName=" + username + ")")
def setUp(self):
+ super(DescriptorTests, self).setUp()
self.ldb_admin = ldb
self.base_dn = self.find_basedn(self.ldb_admin)
self.configuration_dn = self.find_configurationdn(self.ldb_admin)
@@ -307,7 +308,7 @@ class OwnerGroupDescriptorTests(DescriptorTests):
self.delete_force(self.ldb_admin, "CN=test-container1,CN=DisplaySpecifiers," + self.configuration_dn)
def setUp(self):
- DescriptorTests.setUp(self)
+ super(OwnerGroupDescriptorTests, self).setUp()
self.deleteAll()
### Create users
# User 1
@@ -453,6 +454,7 @@ class OwnerGroupDescriptorTests(DescriptorTests):
self.DS_BEHAVIOR = "ds_behavior_win2008"
def tearDown(self):
+ super(DescriptorTests, self).tearDown()
self.deleteAll()
def check_user_belongs(self, user_dn, groups=[]):
@@ -1364,10 +1366,7 @@ class DaclDescriptorTests(DescriptorTests):
self.delete_force(self.ldb_admin, "OU=test_inherit_ou," + self.base_dn)
def setUp(self):
- DescriptorTests.setUp(self)
- self.deleteAll()
-
- def tearDown(self):
+ super(DaclDescriptorTests, self).setUp()
self.deleteAll()
def create_clean_ou(self, object_dn):
@@ -1696,13 +1695,10 @@ class SdFlagsDescriptorTests(DescriptorTests):
self.delete_force(self.ldb_admin, "OU=test_sdflags_ou," + self.base_dn)
def setUp(self):
- DescriptorTests.setUp(self)
+ super(SdFlagsDescriptorTests, self).setUp()
self.test_descr = "O:AUG:AUD:(D;;CC;;;LG)S:(OU;;WP;;;AU)"
self.deleteAll()
- def tearDown(self):
- self.deleteAll()
-
def test_301(self):
""" Modify a descriptor with OWNER_SECURITY_INFORMATION set.
See that only the owner has been changed.
@@ -1849,6 +1845,7 @@ class SdFlagsDescriptorTests(DescriptorTests):
self.assertFalse("S:" in desc_sddl)
self.assertFalse("G:" in desc_sddl)
+
class RightsAttributesTests(DescriptorTests):
def deleteAll(self):
@@ -1857,7 +1854,7 @@ class RightsAttributesTests(DescriptorTests):
self.delete_force(self.ldb_admin, "OU=test_domain_ou1," + self.base_dn)
def setUp(self):
- DescriptorTests.setUp(self)
+ super(RightsAttributesTests, self).setUp()
self.deleteAll()
### Create users
# User 1
@@ -1866,9 +1863,6 @@ class RightsAttributesTests(DescriptorTests):
self.create_enable_user("testuser_attr2")
self.add_user_to_group(self.ldb_admin, "testuser_attr2", "Domain Admins")
- def tearDown(self):
- self.deleteAll()
-
def test_sDRightsEffective(self):
object_dn = "OU=test_domain_ou1," + self.base_dn
self.delete_force(self.ldb_admin, object_dn)
diff --git a/source4/lib/ldb/tests/python/urgent_replication.py b/source4/lib/ldb/tests/python/urgent_replication.py
index 78200efc30..26f7d9b46d 100755
--- a/source4/lib/ldb/tests/python/urgent_replication.py
+++ b/source4/lib/ldb/tests/python/urgent_replication.py
@@ -15,6 +15,7 @@ from samba.auth import system_session
from ldb import (SCOPE_BASE, LdbError, ERR_NO_SUCH_OBJECT, Message,
MessageElement, Dn, FLAG_MOD_REPLACE)
from samba.samdb import SamDB
+import samba.tests
from subunit.run import SubunitTestRunner
import unittest
@@ -37,7 +38,7 @@ host = args[0]
lp = sambaopts.get_loadparm()
creds = credopts.get_credentials(lp)
-class UrgentReplicationTests(unittest.TestCase):
+class UrgentReplicationTests(samba.tests.TestCase):
def delete_force(self, ldb, dn):
try:
@@ -52,6 +53,7 @@ class UrgentReplicationTests(unittest.TestCase):
return res[0]["defaultNamingContext"][0]
def setUp(self):
+ super(UrgentReplicationTests, self).setUp()
self.ldb = ldb
self.base_dn = self.find_basedn(ldb)
diff --git a/source4/lib/messaging/tests/bindings.py b/source4/lib/messaging/tests/bindings.py
index 8240a364b0..91cf024555 100644
--- a/source4/lib/messaging/tests/bindings.py
+++ b/source4/lib/messaging/tests/bindings.py
@@ -19,9 +19,10 @@
#
from samba.messaging import Messaging
-from unittest import TestCase
+from samba.tests import TestCase
class MessagingTests(TestCase):
+
def get_context(self, *args, **kwargs):
kwargs["messaging_path"] = "."
return Messaging(*args, **kwargs)
diff --git a/source4/lib/registry/tests/bindings.py b/source4/lib/registry/tests/bindings.py
index b5115aefa4..d01ebff909 100644
--- a/source4/lib/registry/tests/bindings.py
+++ b/source4/lib/registry/tests/bindings.py
@@ -18,11 +18,11 @@
#
import os
-import unittest
from samba import registry
import samba.tests
-class HelperTests(unittest.TestCase):
+class HelperTests(samba.tests.TestCase):
+
def test_predef_to_name(self):
self.assertEquals("HKEY_LOCAL_MACHINE",
registry.get_predef_name(0x80000002))
@@ -33,6 +33,7 @@ class HelperTests(unittest.TestCase):
class HiveTests(samba.tests.TestCaseInTempDir):
+
def setUp(self):
super(HiveTests, self).setUp()
self.hive_path = os.path.join(self.tempdir, "ldb_new.ldb")
@@ -41,6 +42,7 @@ class HiveTests(samba.tests.TestCaseInTempDir):
def tearDown(self):
del self.hive
os.unlink(self.hive_path)
+ super(HiveTests, self).tearDown()
def test_ldb_new(self):
self.assertTrue(self.hive is not None)
@@ -52,6 +54,7 @@ class HiveTests(samba.tests.TestCaseInTempDir):
# self.hive.del_value("FOO")
-class RegistryTests(unittest.TestCase):
+class RegistryTests(samba.tests.TestCase):
+
def test_new(self):
self.registry = registry.Registry()
diff --git a/source4/libcli/security/tests/bindings.py b/source4/libcli/security/tests/bindings.py
index 1869728fbf..22f7df6b1c 100644
--- a/source4/libcli/security/tests/bindings.py
+++ b/source4/libcli/security/tests/bindings.py
@@ -17,11 +17,13 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-import unittest
+import samba.tests
from samba.dcerpc import security
-class SecurityTokenTests(unittest.TestCase):
+class SecurityTokenTests(samba.tests.TestCase):
+
def setUp(self):
+ super(SecurityTokenTests, self).setUp()
self.token = security.token()
def test_is_system(self):
@@ -45,9 +47,10 @@ class SecurityTokenTests(unittest.TestCase):
self.assertTrue(self.token.has_privilege(security.SEC_PRIV_SHUTDOWN))
-class SecurityDescriptorTests(unittest.TestCase):
+class SecurityDescriptorTests(samba.tests.TestCase):
def setUp(self):
+ super(SecurityDescriptorTests, self).setUp()
self.descriptor = security.descriptor()
def test_from_sddl(self):
@@ -62,11 +65,12 @@ class SecurityDescriptorTests(unittest.TestCase):
self.assertRaises(TypeError,security.descriptor.from_sddl, "foo",security.dom_sid("S-2-0-0"))
def test_from_sddl_invalidtype1(self):
- self.assertRaises(TypeError,security.descriptor.from_sddl, security.dom_sid('S-2-0-0-512'),security.dom_sid("S-2-0-0"))
+ self.assertRaises(TypeError, security.descriptor.from_sddl, security.dom_sid('S-2-0-0-512'),security.dom_sid("S-2-0-0"))
- def test_from_sddl_invalidtype1(self):
+ def test_from_sddl_invalidtype2(self):
sddl = "O:AOG:DAD:(A;;RPWPCCDCLCSWRCWDWOGA;;;S-1-0-0)"
- self.assertRaises(TypeError,security.descriptor.from_sddl, sddl,"S-2-0-0")
+ self.assertRaises(TypeError, security.descriptor.from_sddl, sddl,
+ "S-2-0-0")
def test_as_sddl(self):
text = "O:AOG:DAD:(A;;RPWPCCDCLCSWRCWDWOGA;;;S-1-0-0)"
@@ -106,7 +110,8 @@ class SecurityDescriptorTests(unittest.TestCase):
self.assertEquals((security.dom_sid("S-2-0"), 7), dom.split())
-class DomSidTests(unittest.TestCase):
+class DomSidTests(samba.tests.TestCase):
+
def test_parse_sid(self):
sid = security.dom_sid("S-1-5-21")
self.assertEquals("S-1-5-21", str(sid))
@@ -126,10 +131,13 @@ class DomSidTests(unittest.TestCase):
self.assertTrue(repr(sid).startswith("dom_sid('S-1-5-21-"))
-class PrivilegeTests(unittest.TestCase):
+class PrivilegeTests(samba.tests.TestCase):
+
def test_privilege_name(self):
- self.assertEquals("SeShutdownPrivilege", security.privilege_name(security.SEC_PRIV_SHUTDOWN))
+ self.assertEquals("SeShutdownPrivilege",
+ security.privilege_name(security.SEC_PRIV_SHUTDOWN))
def test_privilege_id(self):
- self.assertEquals(security.SEC_PRIV_SHUTDOWN, security.privilege_id("SeShutdownPrivilege"))
+ self.assertEquals(security.SEC_PRIV_SHUTDOWN,
+ security.privilege_id("SeShutdownPrivilege"))
diff --git a/source4/param/tests/bindings.py b/source4/param/tests/bindings.py
index 1915e79223..1e393abbcd 100644
--- a/source4/param/tests/bindings.py
+++ b/source4/param/tests/bindings.py
@@ -18,9 +18,10 @@
#
from samba import param
-import unittest
+import samba.tests
+
+class LoadParmTestCase(samba.tests.TestCase):
-class LoadParmTestCase(unittest.TestCase):
def test_init(self):
file = param.LoadParm()
self.assertTrue(file is not None)
diff --git a/source4/scripting/python/samba/tests/__init__.py b/source4/scripting/python/samba/tests/__init__.py
index 78c4676aa7..0583f8856a 100644
--- a/source4/scripting/python/samba/tests/__init__.py
+++ b/source4/scripting/python/samba/tests/__init__.py
@@ -30,9 +30,10 @@ from testtools.testcase import TestCase, TestSkipped
class LdbTestCase(TestCase):
-
"""Trivial test case for running tests against a LDB."""
+
def setUp(self):
+ super(LdbTestCase, self).setUp()
self.filename = os.tempnam()
self.ldb = samba.Ldb(self.filename)
@@ -63,14 +64,16 @@ class SubstituteVarTestCase(TestCase):
self.assertEquals("", samba.substitute_var("", {}))
def test_nothing(self):
- self.assertEquals("foo bar", samba.substitute_var("foo bar", {"bar": "bla"}))
+ self.assertEquals("foo bar",
+ samba.substitute_var("foo bar", {"bar": "bla"}))
def test_replace(self):
- self.assertEquals("foo bla", samba.substitute_var("foo ${bar}", {"bar": "bla"}))
+ self.assertEquals("foo bla",
+ samba.substitute_var("foo ${bar}", {"bar": "bla"}))
def test_broken(self):
self.assertEquals("foo ${bdkjfhsdkfh sdkfh ",
- samba.substitute_var("foo ${bdkjfhsdkfh sdkfh ", {"bar": "bla"}))
+ samba.substitute_var("foo ${bdkjfhsdkfh sdkfh ", {"bar": "bla"}))
def test_unknown_var(self):
self.assertEquals("foo ${bla} gsff",
@@ -78,7 +81,8 @@ class SubstituteVarTestCase(TestCase):
def test_check_all_substituted(self):
samba.check_all_substituted("nothing to see here")
- self.assertRaises(Exception, samba.check_all_substituted, "Not subsituted: ${FOOBAR}")
+ self.assertRaises(Exception, samba.check_all_substituted,
+ "Not subsituted: ${FOOBAR}")
class LdbExtensionTests(TestCaseInTempDir):
@@ -88,7 +92,8 @@ class LdbExtensionTests(TestCaseInTempDir):
l = samba.Ldb(path)
try:
l.add({"dn": "foo=dc", "bar": "bla"})
- self.assertEquals("bla", l.searchone(basedn=ldb.Dn(l, "foo=dc"), attribute="bar"))
+ self.assertEquals("bla",
+ l.searchone(basedn=ldb.Dn(l, "foo=dc"), attribute="bar"))
finally:
del l
os.unlink(path)
diff --git a/source4/scripting/python/samba/tests/dcerpc/__init__.py b/source4/scripting/python/samba/tests/dcerpc/__init__.py
index c64c9dc9f6..e2b9b3f001 100644
--- a/source4/scripting/python/samba/tests/dcerpc/__init__.py
+++ b/source4/scripting/python/samba/tests/dcerpc/__init__.py
@@ -16,5 +16,5 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
+
diff --git a/source4/scripting/python/samba/tests/dcerpc/bare.py b/source4/scripting/python/samba/tests/dcerpc/bare.py
index e6811b0a3d..4051052b0c 100644
--- a/source4/scripting/python/samba/tests/dcerpc/bare.py
+++ b/source4/scripting/python/samba/tests/dcerpc/bare.py
@@ -19,31 +19,32 @@
#
from samba.dcerpc import ClientConnection
-from unittest import TestCase
-from samba.tests import env_loadparm
+import samba.tests
-
-class BareTestCase(TestCase):
+class BareTestCase(samba.tests.TestCase):
def test_bare(self):
# Connect to the echo pipe
x = ClientConnection("ncalrpc:localhost[DEFAULT]",
- ("60a15ec5-4de8-11d7-a637-005056a20182", 1), lp_ctx=env_loadparm())
+ ("60a15ec5-4de8-11d7-a637-005056a20182", 1),
+ lp_ctx=samba.tests.env_loadparm())
self.assertEquals("\x01\x00\x00\x00", x.request(0, chr(0) * 4))
def test_alter_context(self):
x = ClientConnection("ncalrpc:localhost[DEFAULT]",
- ("12345778-1234-abcd-ef00-0123456789ac", 1), lp_ctx=env_loadparm())
+ ("12345778-1234-abcd-ef00-0123456789ac", 1),
+ lp_ctx=samba.tests.env_loadparm())
y = ClientConnection("ncalrpc:localhost",
("60a15ec5-4de8-11d7-a637-005056a20182", 1),
- basis_connection=x, lp_ctx=env_loadparm())
+ basis_connection=x, lp_ctx=samba.tests.env_loadparm())
x.alter_context(("60a15ec5-4de8-11d7-a637-005056a20182", 1))
# FIXME: self.assertEquals("\x01\x00\x00\x00", x.request(0, chr(0) * 4))
def test_two_connections(self):
x = ClientConnection("ncalrpc:localhost[DEFAULT]",
- ("60a15ec5-4de8-11d7-a637-005056a20182", 1), lp_ctx=env_loadparm())
+ ("60a15ec5-4de8-11d7-a637-005056a20182", 1),
+ lp_ctx=samba.tests.env_loadparm())
y = ClientConnection("ncalrpc:localhost",
("60a15ec5-4de8-11d7-a637-005056a20182", 1),
- basis_connection=x, lp_ctx=env_loadparm())
+ basis_connection=x, lp_ctx=samba.tests.env_loadparm())
self.assertEquals("\x01\x00\x00\x00", y.request(0, chr(0) * 4))
diff --git a/source4/scripting/python/samba/tests/dcerpc/misc.py b/source4/scripting/python/samba/tests/dcerpc/misc.py
index ab76efc536..2adf86aa9e 100644
--- a/source4/scripting/python/samba/tests/dcerpc/misc.py
+++ b/source4/scripting/python/samba/tests/dcerpc/misc.py
@@ -17,13 +17,13 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-import unittest
from samba.dcerpc import misc
+import samba.tests
text1 = "76f53846-a7c2-476a-ae2c-20e2b80d7b34"
text2 = "344edffa-330a-4b39-b96e-2c34da52e8b1"
-class GUIDTests(unittest.TestCase):
+class GUIDTests(samba.tests.TestCase):
def test_str(self):
guid = misc.GUID(text1)
@@ -45,7 +45,7 @@ class GUIDTests(unittest.TestCase):
self.assertEquals(guid1, guid2)
-class PolicyHandleTests(unittest.TestCase):
+class PolicyHandleTests(samba.tests.TestCase):
def test_init(self):
x = misc.policy_handle(text1, 1)
diff --git a/source4/scripting/python/samba/tests/dcerpc/registry.py b/source4/scripting/python/samba/tests/dcerpc/registry.py
index f1cd83790d..5ff256ed01 100644
--- a/source4/scripting/python/samba/tests/dcerpc/registry.py
+++ b/source4/scripting/python/samba/tests/dcerpc/registry.py
@@ -24,6 +24,7 @@ from samba.tests import RpcInterfaceTestCase
class WinregTests(RpcInterfaceTestCase):
def setUp(self):
+ super(WinregTests, self).setUp()
self.conn = winreg.winreg("ncalrpc:", self.get_loadparm(),
self.get_credentials())
diff --git a/source4/scripting/python/samba/tests/dcerpc/rpcecho.py b/source4/scripting/python/samba/tests/dcerpc/rpcecho.py
index 72eb87d750..f1f765c990 100644
--- a/source4/scripting/python/samba/tests/dcerpc/rpcecho.py
+++ b/source4/scripting/python/samba/tests/dcerpc/rpcecho.py
@@ -19,13 +19,13 @@
from samba.dcerpc import echo
from samba.ndr import ndr_pack, ndr_unpack
-import unittest
-from samba.tests import RpcInterfaceTestCase
+from samba.tests import RpcInterfaceTestCase, TestCase
class RpcEchoTests(RpcInterfaceTestCase):
def setUp(self):
+ super(RpcEchoTests, self).setUp()
self.conn = echo.rpcecho("ncalrpc:", self.get_loadparm())
def test_two_contexts(self):
@@ -59,7 +59,7 @@ class RpcEchoTests(RpcInterfaceTestCase):
self.assertEquals(None, self.conn.server_name)
-class NdrEchoTests(unittest.TestCase):
+class NdrEchoTests(TestCase):
def test_info1_push(self):
x = echo.info1()
diff --git a/source4/scripting/python/samba/tests/dcerpc/sam.py b/source4/scripting/python/samba/tests/dcerpc/sam.py
index 333f8d12b5..df943a11ba 100644
--- a/source4/scripting/python/samba/tests/dcerpc/sam.py
+++ b/source4/scripting/python/samba/tests/dcerpc/sam.py
@@ -32,6 +32,7 @@ def toArray((handle, array, num_entries)):
class SamrTests(RpcInterfaceTestCase):
def setUp(self):
+ super(SamrTests, self).setUp()
self.conn = samr.samr("ncalrpc:", self.get_loadparm())
def test_connect5(self):
diff --git a/source4/scripting/python/samba/tests/dcerpc/unix.py b/source4/scripting/python/samba/tests/dcerpc/unix.py
index 62169ad12c..7a3e715685 100644
--- a/source4/scripting/python/samba/tests/dcerpc/unix.py
+++ b/source4/scripting/python/samba/tests/dcerpc/unix.py
@@ -23,6 +23,7 @@ from samba.tests import RpcInterfaceTestCase
class UnixinfoTests(RpcInterfaceTestCase):
def setUp(self):
+ super(UnixinfoTests, self).setUp()
self.conn = unixinfo.unixinfo("ncalrpc:", self.get_loadparm())
def test_getpwuid(self):
diff --git a/source4/scripting/python/samba/tests/netcmd.py b/source4/scripting/python/samba/tests/netcmd.py
index ecd8dc439e..4b911facf1 100644
--- a/source4/scripting/python/samba/tests/netcmd.py
+++ b/source4/scripting/python/samba/tests/netcmd.py
@@ -17,11 +17,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-import unittest
-
from samba.netcmd import Command
+import samba.tests
-class CommandTests(unittest.TestCase):
+class CommandTests(samba.tests.TestCase):
def test_name(self):
class cmd_foo(Command):
diff --git a/source4/scripting/python/samba/tests/provision.py b/source4/scripting/python/samba/tests/provision.py
index 22e4553f02..dd18aa0ff6 100644
--- a/source4/scripting/python/samba/tests/provision.py
+++ b/source4/scripting/python/samba/tests/provision.py
@@ -20,8 +20,7 @@
import os
from samba.provision import setup_secretsdb, findnss
import samba.tests
-from samba.tests import env_loadparm
-import unittest
+from samba.tests import env_loadparm, TestCase
setup_dir = "setup"
def setup_path(file):
@@ -42,8 +41,9 @@ class ProvisionTestCase(samba.tests.TestCaseInTempDir):
os.unlink(path)
-class FindNssTests(unittest.TestCase):
+class FindNssTests(TestCase):
"""Test findnss() function."""
+
def test_nothing(self):
def x(y):
raise KeyError
diff --git a/source4/scripting/python/samba/tests/samba3.py b/source4/scripting/python/samba/tests/samba3.py
index d7418b303d..f81ef486c0 100644
--- a/source4/scripting/python/samba/tests/samba3.py
+++ b/source4/scripting/python/samba/tests/samba3.py
@@ -24,8 +24,8 @@ from samba.samba3 import (WinsDatabase, SmbpasswdFile, ACB_NORMAL,
from samba.tests import TestCase
import os
-DATADIR=os.path.join(os.path.dirname(__file__), "../../../../../testdata/samba3")
-print "Samba 3 data dir: %s" % DATADIR
+DATADIR = os.path.join(os.path.dirname(__file__),
+ "../../../../../testdata/samba3")
class RegistryTestCase(TestCase):
@@ -35,6 +35,7 @@ class RegistryTestCase(TestCase):
def tearDown(self):
self.registry.close()
+ super(RegistryTestCase, self).tearDown()
def test_length(self):
self.assertEquals(28, len(self.registry))
diff --git a/source4/scripting/python/samba/tests/shares.py b/source4/scripting/python/samba/tests/shares.py
index 160e3cf883..10f17503e5 100644
--- a/source4/scripting/python/samba/tests/shares.py
+++ b/source4/scripting/python/samba/tests/shares.py
@@ -17,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from samba.shares import SharesContainer
-from unittest import TestCase
+from samba.tests import TestCase
class MockService(object):
diff --git a/source4/scripting/python/samba/tests/upgrade.py b/source4/scripting/python/samba/tests/upgrade.py
index 67a89a3dbc..56180071f8 100644
--- a/source4/scripting/python/samba/tests/upgrade.py
+++ b/source4/scripting/python/samba/tests/upgrade.py
@@ -21,6 +21,7 @@ from samba.upgrade import import_wins
from samba.tests import LdbTestCase
class WinsUpgradeTests(LdbTestCase):
+
def test_upgrade(self):
winsdb = {
"FOO#20": (200, ["127.0.0.1", "127.0.0.2"], 0x60)
diff --git a/source4/scripting/python/samba/tests/xattr.py b/source4/scripting/python/samba/tests/xattr.py
index 9bfe52c67e..32999984ea 100644
--- a/source4/scripting/python/samba/tests/xattr.py
+++ b/source4/scripting/python/samba/tests/xattr.py
@@ -20,7 +20,7 @@
import samba.xattr_native, samba.xattr_tdb
from samba.dcerpc import xattr
from samba.ndr import ndr_pack
-from testtools.testcase import TestCase, TestSkipped
+from samba.tests import TestCase, TestSkipped
import random
import os
diff --git a/source4/torture/libnet/python/samr-test.py b/source4/torture/libnet/python/samr-test.py
index d68456b79d..211792c1db 100644
--- a/source4/torture/libnet/python/samr-test.py
+++ b/source4/torture/libnet/python/samr-test.py
@@ -26,11 +26,9 @@
# PYTHONPATH="$samba4srcdir/torture/libnet/python" $SUBUNITRUN samr-test -Ukma-exch.devel/Administrator%333
#
-import sys
import os
from samba import net
-import unittest
import samba.tests
if not "ACCOUNT_NAME" in os.environ.keys():
@@ -48,7 +46,7 @@ creds = samba.tests.cmdline_credentials
# Tests start here
#
-class Libnet_SetPwdTest(unittest.TestCase):
+class Libnet_SetPwdTest(samba.tests.TestCase):
########################################################################################