summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlec Warner <antarus@gentoo.org>2007-01-10 13:35:03 +0000
committerAlec Warner <antarus@gentoo.org>2007-01-10 13:35:03 +0000
commitbe41793f50c29aa6c0d17a8616ce214b71d81e0a (patch)
treedbfe6b7453a13e047319f3f3254aaa16c9f5a95e
parent2b95943f707bec5fcf4f360cdb26e372392fa177 (diff)
downloadportage-be41793f50c29aa6c0d17a8616ce214b71d81e0a.tar.gz
portage-be41793f50c29aa6c0d17a8616ce214b71d81e0a.tar.bz2
portage-be41793f50c29aa6c0d17a8616ce214b71d81e0a.zip
Take Genone's suggestion and break the modules up into module oriented fashion. Tests for portage.py go in portage/ and so on and so forth...
svn path=/main/trunk/; revision=5525
-rw-r--r--tests/__init__.py32
-rw-r--r--tests/portage/__init__.py4
-rw-r--r--tests/portage/test_atoms.py (renamed from tests/test_atoms.py)0
-rw-r--r--tests/portage_util/__init__.py5
-rw-r--r--tests/portage_util/test_util.py (renamed from tests/test_util.py)0
5 files changed, 34 insertions, 7 deletions
diff --git a/tests/__init__.py b/tests/__init__.py
index a32ca05d3..71d699770 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -7,16 +7,34 @@ import unittest
def main():
- tests = ["test_atoms", "test_util"]
+ testDirs = ["portage/", "portage_util/"]
suite = unittest.TestSuite()
- for mod in tests:
+ for dir in testDirs:
+ suite.addTests(getTests(dir))
+
+ return unittest.TextTestRunner(verbosity=2).run(suite)
+
+def getTests( path ):
+ """
+
+ path is the path to a given subdir ( 'portage/' for example)
+ This does a simple filter on files in that dir to give us modules
+ to import
+
+ """
+ import os
+ files = os.listdir( path )
+ files = [ f[:-3] for f in files if f.startswith("test_") and f.endswith(".py") ]
+
+ result = []
+ for file in files:
try:
- loadMod = __import__(mod)
- tmpSuite = unittest.TestLoader().loadTestsFromModule(loadMod)
- suite.addTest(tmpSuite)
+ # Make the trailing / a . for module importing
+ path2 = path[:-1] + "." + file
+ mod = __import__( path2, globals(), locals(), [path[-1]])
+ result.append( unittest.TestLoader().loadTestsFromModule(mod) )
except ImportError:
pass
-
- return unittest.TextTestRunner(verbosity=2).run(suite)
+ return result
diff --git a/tests/portage/__init__.py b/tests/portage/__init__.py
new file mode 100644
index 000000000..e1c0ae595
--- /dev/null
+++ b/tests/portage/__init__.py
@@ -0,0 +1,4 @@
+# tests/portage/__init__.py -- Portage Unit Test functionality
+# Copyright 2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id: __init__.py 5522 2007-01-10 12:30:05Z antarus $
diff --git a/tests/test_atoms.py b/tests/portage/test_atoms.py
index d051fed22..d051fed22 100644
--- a/tests/test_atoms.py
+++ b/tests/portage/test_atoms.py
diff --git a/tests/portage_util/__init__.py b/tests/portage_util/__init__.py
new file mode 100644
index 000000000..ede012f66
--- /dev/null
+++ b/tests/portage_util/__init__.py
@@ -0,0 +1,5 @@
+# tests/portage_util/__init__.py -- Portage Unit Test functionality
+# Copyright 2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id: __init__.py 5522 2007-01-10 12:30:05Z antarus $
+
diff --git a/tests/test_util.py b/tests/portage_util/test_util.py
index e16da6c1d..e16da6c1d 100644
--- a/tests/test_util.py
+++ b/tests/portage_util/test_util.py