Move tests/ to top level of trunk/. Fix tests to run from new location. Add
authorTodd Larsen <tlarsen@google.com>
Mon, 04 Aug 2008 22:38:35 +0000
changeset 63 9b1909e46633
parent 62 1627b79c396a
child 64 b73eec62825a
Move tests/ to top level of trunk/. Fix tests to run from new location. Add missing __init__.py modules to make relative imports from tests work properly.
__init__.py
app/__init__.py
scripts/svn_helper.py
scripts/tests/__init__.py
scripts/tests/bad_test_settings
scripts/tests/good_test_settings
scripts/tests/settings_test.py
scripts/tests/svn_helper_test.py
tests/__init__.py
tests/bad_test_settings
tests/good_test_settings
tests/settings_test.py
tests/svn_helper_test.py
--- a/scripts/svn_helper.py	Mon Aug 04 22:09:35 2008 +0000
+++ b/scripts/svn_helper.py	Mon Aug 04 22:38:35 2008 +0000
@@ -23,6 +23,8 @@
 
 PYSVN_ALL_NODE_KINDS: all directory entry node_kinds supported by pysvn
 PYSVN_FILE_DIR_NODE_KINDS: actual file and directory node_kinds
+
+This module requires that the pysvn module be installed.
 """
 
 __authors__ = [
--- a/scripts/tests/bad_test_settings	Mon Aug 04 22:09:35 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-# test settings file with syntax error
-
-undefined_symbol
-
--- a/scripts/tests/good_test_settings	Mon Aug 04 22:09:35 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-# test settings file with no errors
-
-foo = 3
-bar = foo
-
--- a/scripts/tests/settings_test.py	Mon Aug 04 22:09:35 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,121 +0,0 @@
-#!/usr/bin/python2.5
-#
-# Copyright 2008 the Melange authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Tests for the scripts.settings module.
-
-
-For details on running the tests, see:
-  http://code.google.com/p/soc/wiki/TestingGuidelines#Running_the_smoke_tests
-"""
-
-__authors__ = [
-  # alphabetical order by last name, please
-  '"Todd Larsen" <tlarsen@google.com>',
-]
-
-
-import optparse
-import os
-import sys
-import unittest
-
-from .. import settings
-
-
-class SettingsTests(unittest.TestCase):
-  """Python-format settings file tests for the settings.py module.
-  """
-
-  def setUp(self):
-    self.test_srcdir = os.path.dirname(__file__)
-    self.settings_defaults = {'foo': 1, 'bif': 4}
-
-  def testMissingPythonSettings(self):
-    """Test that non-existent files work properly without errors.
-    """
-    # non-existent settings file with no defaults produces empty dict
-    self.assertEqual(
-        {},
-        settings.readPythonSettings(settings_dir=self.test_srcdir,
-                                    settings_file='nonexistent_file'))
-
-    # non-existent settings file should just pass through the defaults
-    self.assertEqual(
-        self.settings_defaults,
-        settings.readPythonSettings(defaults=self.settings_defaults,
-                                    settings_dir=self.test_srcdir,
-                                    settings_file='nonexistent_file'))
-
-  def testGoodPythonSettings(self):
-    """Test that settings file that is present overwrites defaults.
-    """
-    # foo and bar are overwritten, but not bif (not in the settings file)
-    self.assertEqual(
-        {'foo': 3, 'bar': 3, 'bif': 4},
-        settings.readPythonSettings(defaults=self.settings_defaults,
-                                    settings_dir=self.test_srcdir,
-                                    settings_file='good_test_settings'))
-
-    # but the original defaults will be untouched
-    self.assertEqual({'foo': 1, 'bif': 4}, self.settings_defaults)
-
-  def testBadPythonSettings(self):
-    """Test that exception is raised when format of settings file is bad.
-    """
-    self.assertRaises(settings.Error, settings.readPythonSettings,
-                      settings_dir=self.test_srcdir,
-                      settings_file='bad_test_settings')
-
-
-class OptionParserTests(unittest.TestCase):
-  """Tests of custom optparse OptionParser with 'required' parameter support.
-  """
-
-  def testRequiredPresent(self):
-    """Test required=True raises nothing when value option is present.
-    """
-    parser = settings.OptionParser(
-      option_list=[
-        settings.Option(
-            '-t', '--test', action='store', dest='test', required=True,
-            help='(REQUIRED) test option'),
-        ],
-      )
-
-    options, args = parser.parse_args([sys.argv[0], '--test', '3'])
-
-  def testRequiredMissing(self):
-    """Test that Error exception is raised if required option not present.
-    """
-    parser = settings.OptionParser(
-      option_list=[
-        settings.Option(
-            '-t', '--test', action='store', dest='test', required=True,
-            help='(REQUIRED) test option'),
-        ],
-      )
-
-    self.assertRaises(settings.Error, parser.parse_args, [])
-
-  def testBadRequiredAction(self):
-    """Test that OptionError is raised if action does not support required=True.
-    """
-
-    # store_true is not in Options.TYPED_VALUES, which means option cannot
-    # take a value, so required=True is not permitted.
-    self.assertRaises(optparse.OptionError, settings.Option,
-        '-t', '--test', action='store_true', dest='test', required=True,
-        help='(REQUIRED) test option')
--- a/scripts/tests/svn_helper_test.py	Mon Aug 04 22:09:35 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-#!/usr/bin/python2.5
-#
-# Copyright 2008 the Melange authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Tests for the scripts.svn_helper module.
-
-For details on running the tests, see:
-  http://code.google.com/p/soc/wiki/TestingGuidelines#Running_the_smoke_tests
-"""
-
-__authors__ = [
-  # alphabetical order by last name, please
-  '"Todd Larsen" <tlarsen@google.com>',
-]
-
-
-import os
-import pysvn
-import sys
-import unittest
-
-from .. import svn_helper
-
-
-class SvnHelperTests(unittest.TestCase):
-  """pysvn wrapper tests for the svn_helper.py module.
-  """
-
-  def setUp(self):
-    self.client = pysvn.Client()
-
-  def testLsFiles(self):
-    """Test if lsFiles() contains only file entries, using the SoC SVN repo.
-    """
-    self.assert_(
-        'svn_helper_test.py' in svn_helper.lsFiles(
-            self.client, '%strunk/scripts/tests' % svn_helper.DEF_SVN_REPO))
-
-    self.assert_(
-        'tests/' not in svn_helper.lsFiles(
-            self.client, '%strunk/scripts' % svn_helper.DEF_SVN_REPO))
-
-  def testLsDirs(self):
-    """Test if lsDirs() contains only dir entries, using the SoC SVN repo.
-    """
-    self.assert_(
-        'tests/' in svn_helper.lsDirs(
-            self.client, '%strunk/scripts' % svn_helper.DEF_SVN_REPO))
-
-    self.assert_(
-        'svn_helper_test.py' not in svn_helper.lsDirs(
-            self.client, '%strunk/scripts' % svn_helper.DEF_SVN_REPO))
-
-  def testExists(self):
-    """Test if exists() works on the the SoC SVN repo.
-    """
-    self.assertEqual(
-        True, svn_helper.exists(self.client,
-                                svn_helper.DEF_SVN_REPO + 'trunk'))
-
-    self.assertEqual(
-        False, svn_helper.exists(self.client,
-                                 svn_helper.DEF_SVN_REPO + 'does_not_exist'))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/bad_test_settings	Mon Aug 04 22:38:35 2008 +0000
@@ -0,0 +1,4 @@
+# test settings file with syntax error
+
+undefined_symbol
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/good_test_settings	Mon Aug 04 22:38:35 2008 +0000
@@ -0,0 +1,5 @@
+# test settings file with no errors
+
+foo = 3
+bar = foo
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/settings_test.py	Mon Aug 04 22:38:35 2008 +0000
@@ -0,0 +1,121 @@
+#!/usr/bin/python2.5
+#
+# Copyright 2008 the Melange authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""Tests for the scripts.settings module.
+
+
+For details on running the tests, see:
+  http://code.google.com/p/soc/wiki/TestingGuidelines#Running_the_smoke_tests
+"""
+
+__authors__ = [
+  # alphabetical order by last name, please
+  '"Todd Larsen" <tlarsen@google.com>',
+]
+
+
+import optparse
+import os
+import sys
+import unittest
+
+from ..scripts import settings
+
+
+class SettingsTests(unittest.TestCase):
+  """Python-format settings file tests for the settings.py module.
+  """
+
+  def setUp(self):
+    self.test_srcdir = os.path.dirname(__file__)
+    self.settings_defaults = {'foo': 1, 'bif': 4}
+
+  def testMissingPythonSettings(self):
+    """Test that non-existent files work properly without errors.
+    """
+    # non-existent settings file with no defaults produces empty dict
+    self.assertEqual(
+        {},
+        settings.readPythonSettings(settings_dir=self.test_srcdir,
+                                    settings_file='nonexistent_file'))
+
+    # non-existent settings file should just pass through the defaults
+    self.assertEqual(
+        self.settings_defaults,
+        settings.readPythonSettings(defaults=self.settings_defaults,
+                                    settings_dir=self.test_srcdir,
+                                    settings_file='nonexistent_file'))
+
+  def testGoodPythonSettings(self):
+    """Test that settings file that is present overwrites defaults.
+    """
+    # foo and bar are overwritten, but not bif (not in the settings file)
+    self.assertEqual(
+        {'foo': 3, 'bar': 3, 'bif': 4},
+        settings.readPythonSettings(defaults=self.settings_defaults,
+                                    settings_dir=self.test_srcdir,
+                                    settings_file='good_test_settings'))
+
+    # but the original defaults will be untouched
+    self.assertEqual({'foo': 1, 'bif': 4}, self.settings_defaults)
+
+  def testBadPythonSettings(self):
+    """Test that exception is raised when format of settings file is bad.
+    """
+    self.assertRaises(settings.Error, settings.readPythonSettings,
+                      settings_dir=self.test_srcdir,
+                      settings_file='bad_test_settings')
+
+
+class OptionParserTests(unittest.TestCase):
+  """Tests of custom optparse OptionParser with 'required' parameter support.
+  """
+
+  def testRequiredPresent(self):
+    """Test required=True raises nothing when value option is present.
+    """
+    parser = settings.OptionParser(
+      option_list=[
+        settings.Option(
+            '-t', '--test', action='store', dest='test', required=True,
+            help='(REQUIRED) test option'),
+        ],
+      )
+
+    options, args = parser.parse_args([sys.argv[0], '--test', '3'])
+
+  def testRequiredMissing(self):
+    """Test that Error exception is raised if required option not present.
+    """
+    parser = settings.OptionParser(
+      option_list=[
+        settings.Option(
+            '-t', '--test', action='store', dest='test', required=True,
+            help='(REQUIRED) test option'),
+        ],
+      )
+
+    self.assertRaises(settings.Error, parser.parse_args, [])
+
+  def testBadRequiredAction(self):
+    """Test that OptionError is raised if action does not support required=True.
+    """
+
+    # store_true is not in Options.TYPED_VALUES, which means option cannot
+    # take a value, so required=True is not permitted.
+    self.assertRaises(optparse.OptionError, settings.Option,
+        '-t', '--test', action='store_true', dest='test', required=True,
+        help='(REQUIRED) test option')
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/svn_helper_test.py	Mon Aug 04 22:38:35 2008 +0000
@@ -0,0 +1,77 @@
+#!/usr/bin/python2.5
+#
+# Copyright 2008 the Melange authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""Tests for the scripts.svn_helper module.
+
+For details on running the tests, see:
+  http://code.google.com/p/soc/wiki/TestingGuidelines#Running_the_smoke_tests
+
+This test (and the svn_helper module that it tests) requires the pysvn module.
+"""
+
+__authors__ = [
+  # alphabetical order by last name, please
+  '"Todd Larsen" <tlarsen@google.com>',
+]
+
+
+import os
+import pysvn
+import sys
+import unittest
+
+from ..scripts import svn_helper
+
+
+class SvnHelperTests(unittest.TestCase):
+  """pysvn wrapper tests for the svn_helper.py module.
+  """
+
+  def setUp(self):
+    self.client = pysvn.Client()
+
+  def testLsFiles(self):
+    """Test if lsFiles() contains only file entries, using the SoC SVN repo.
+    """
+    self.assert_(
+        'svn_helper_test.py' in svn_helper.lsFiles(
+            'http://soc.googlecode.com/svn/trunk/tests', client=self.client))
+
+    self.assert_(
+        'tests/' not in svn_helper.lsFiles(
+            'http://soc.googlecode.com/svn/trunk', client=self.client))
+
+  def testLsDirs(self):
+    """Test if lsDirs() contains only dir entries, using the SoC SVN repo.
+    """
+    self.assert_(
+        'tests/' in svn_helper.lsDirs(
+            'http://soc.googlecode.com/svn/trunk', client=self.client))
+
+    self.assert_(
+        'svn_helper_test.py' not in svn_helper.lsDirs(
+            'http://soc.googlecode.com/svn/trunk/tests', client=self.client))
+
+  def testExists(self):
+    """Test if exists() works on the the SoC SVN repo.
+    """
+    self.assertEqual(
+        True, svn_helper.exists(
+            'http://soc.googlecode.com/svn/trunk', client=self.client))
+
+    self.assertEqual(
+        False, svn_helper.exists(
+            'http://soc.googlecode.com/svn/does_not_exist', client=self.client))