[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Subdirectories for integ and unit tests



commit d38b8830804e78cd0921333c39c5e9a2ee8ad42f
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sat Oct 8 13:10:38 2011 -0700

    Subdirectories for integ and unit tests
    
    Unit and integration tests will be separate subdirectories of test.
---
 run_tests.py           |    4 +-
 test/__init__.py       |    2 +-
 test/integ/__init__.py |    6 ++
 test/unit/__init__.py  |    6 ++
 test/unit/version.py   |  121 ++++++++++++++++++++++++++++++++++++++++++++++++
 test/version.py        |  121 ------------------------------------------------
 6 files changed, 136 insertions(+), 124 deletions(-)

diff --git a/run_tests.py b/run_tests.py
index 0fe6365..9debfc2 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -5,9 +5,9 @@ Runs unit and integration tests.
 """
 
 import unittest
-import test.version
+import test.unit.version
 
 if __name__ == '__main__':
-  suite = unittest.TestLoader().loadTestsFromTestCase(test.version.TestVerionFunctions)
+  suite = unittest.TestLoader().loadTestsFromTestCase(test.unit.version.TestVerionFunctions)
   unittest.TextTestRunner(verbosity=2).run(suite)
 
diff --git a/test/__init__.py b/test/__init__.py
index 6d651bb..031299c 100644
--- a/test/__init__.py
+++ b/test/__init__.py
@@ -2,5 +2,5 @@
 Unit and integration tests for the stem library.
 """
 
-__all__ = ["version"]
+__all__ = []
 
diff --git a/test/integ/__init__.py b/test/integ/__init__.py
new file mode 100644
index 0000000..b96692a
--- /dev/null
+++ b/test/integ/__init__.py
@@ -0,0 +1,6 @@
+"""
+Integration tests for the stem library.
+"""
+
+__all__ = []
+
diff --git a/test/unit/__init__.py b/test/unit/__init__.py
new file mode 100644
index 0000000..d7db1bd
--- /dev/null
+++ b/test/unit/__init__.py
@@ -0,0 +1,6 @@
+"""
+Unit tests for the stem library.
+"""
+
+__all__ = ["version"]
+
diff --git a/test/unit/version.py b/test/unit/version.py
new file mode 100644
index 0000000..fd32886
--- /dev/null
+++ b/test/unit/version.py
@@ -0,0 +1,121 @@
+"""
+Unit tests for types functions and classes.
+"""
+
+import unittest
+import stem.types
+
+class TestVerionFunctions(unittest.TestCase):
+  """
+  Tests methods and functions related to 'types.Version'.
+  """
+  
+  def test_parsing(self):
+    """
+    Tests parsing by the 'get_version' function.
+    """
+    
+    # valid versions with various number of compontents to the version
+    version = stem.types.get_version("0.1.2.3-tag")
+    self.assert_versions_match(version, 0, 1, 2, 3, "tag")
+    
+    version = stem.types.get_version("0.1.2.3")
+    self.assert_versions_match(version, 0, 1, 2, 3, None)
+    
+    version = stem.types.get_version("0.1.2-tag")
+    self.assert_versions_match(version, 0, 1, 2, None, "tag")
+    
+    version = stem.types.get_version("0.1.2")
+    self.assert_versions_match(version, 0, 1, 2, None, None)
+    
+    # checks an empty tag
+    version = stem.types.get_version("0.1.2.3-")
+    self.assert_versions_match(version, 0, 1, 2, 3, "")
+    
+    version = stem.types.get_version("0.1.2-")
+    self.assert_versions_match(version, 0, 1, 2, None, "")
+    
+    # checks invalid version strings
+    self.assertRaises(ValueError, stem.types.get_version, "")
+    self.assertRaises(ValueError, stem.types.get_version, "1.2.3.4nodash")
+    self.assertRaises(ValueError, stem.types.get_version, "1.2.3.a")
+    self.assertRaises(ValueError, stem.types.get_version, "1.2.a.4")
+    self.assertRaises(ValueError, stem.types.get_version, "12.3")
+    self.assertRaises(ValueError, stem.types.get_version, "1.-2.3")
+  
+  def test_comparison(self):
+    """
+    Tests comparision between Version instances.
+    """
+    
+    # check for basic incrementing in each portion
+    self.assert_version_is_greater("1.1.2.3-tag", "0.1.2.3-tag")
+    self.assert_version_is_greater("0.2.2.3-tag", "0.1.2.3-tag")
+    self.assert_version_is_greater("0.1.3.3-tag", "0.1.2.3-tag")
+    self.assert_version_is_greater("0.1.2.4-tag", "0.1.2.3-tag")
+    self.assert_version_is_greater("0.1.2.3-ugg", "0.1.2.3-tag")
+    self.assert_version_is_equal("0.1.2.3-tag", "0.1.2.3-tag")
+    
+    # checks that a missing patch level equals zero
+    self.assert_version_is_equal("0.1.2", "0.1.2.0")
+    self.assert_version_is_equal("0.1.2-tag", "0.1.2.0-tag")
+    
+    # checks for missing patch or status
+    self.assert_version_is_greater("0.1.2.3-tag", "0.1.2.3")
+    self.assert_version_is_greater("0.1.2.3-tag", "0.1.2-tag")
+    self.assert_version_is_greater("0.1.2.3-tag", "0.1.2")
+    
+    self.assert_version_is_equal("0.1.2.3", "0.1.2.3")
+    self.assert_version_is_equal("0.1.2", "0.1.2")
+  
+  def test_string(self):
+    """
+    Tests the Version -> string conversion.
+    """
+    
+    # checks conversion with various numbers of arguments
+    
+    self.assert_string_matches("0.1.2.3-tag")
+    self.assert_string_matches("0.1.2.3")
+    self.assert_string_matches("0.1.2")
+  
+  def assert_versions_match(self, version, major, minor, micro, patch, status):
+    """
+    Asserts that the values for a types.Version instance match the given
+    values.
+    """
+    
+    self.assertEqual(version.major, major)
+    self.assertEqual(version.minor, minor)
+    self.assertEqual(version.micro, micro)
+    self.assertEqual(version.patch, patch)
+    self.assertEqual(version.status, status)
+  
+  def assert_version_is_greater(self, firstVersion, secondVersion):
+    """
+    Asserts that the parsed version of the first version is greate than the
+    second (also checking the inverse).
+    """
+    
+    version1 = stem.types.get_version(firstVersion)
+    version2 = stem.types.get_version(secondVersion)
+    self.assertEqual(version1 > version2, True)
+    self.assertEqual(version1 < version2, False)
+  
+  def assert_version_is_equal(self, firstVersion, secondVersion):
+    """
+    Asserts that the parsed version of the first version equals the second.
+    """
+    
+    version1 = stem.types.get_version(firstVersion)
+    version2 = stem.types.get_version(secondVersion)
+    self.assertEqual(version1, version2)
+  
+  def assert_string_matches(self, version):
+    """
+    Parses the given version string then checks that its string representation
+    matches the input.
+    """
+    
+    self.assertEqual(version, str(stem.types.get_version(version)))
+
diff --git a/test/version.py b/test/version.py
deleted file mode 100644
index fd32886..0000000
--- a/test/version.py
+++ /dev/null
@@ -1,121 +0,0 @@
-"""
-Unit tests for types functions and classes.
-"""
-
-import unittest
-import stem.types
-
-class TestVerionFunctions(unittest.TestCase):
-  """
-  Tests methods and functions related to 'types.Version'.
-  """
-  
-  def test_parsing(self):
-    """
-    Tests parsing by the 'get_version' function.
-    """
-    
-    # valid versions with various number of compontents to the version
-    version = stem.types.get_version("0.1.2.3-tag")
-    self.assert_versions_match(version, 0, 1, 2, 3, "tag")
-    
-    version = stem.types.get_version("0.1.2.3")
-    self.assert_versions_match(version, 0, 1, 2, 3, None)
-    
-    version = stem.types.get_version("0.1.2-tag")
-    self.assert_versions_match(version, 0, 1, 2, None, "tag")
-    
-    version = stem.types.get_version("0.1.2")
-    self.assert_versions_match(version, 0, 1, 2, None, None)
-    
-    # checks an empty tag
-    version = stem.types.get_version("0.1.2.3-")
-    self.assert_versions_match(version, 0, 1, 2, 3, "")
-    
-    version = stem.types.get_version("0.1.2-")
-    self.assert_versions_match(version, 0, 1, 2, None, "")
-    
-    # checks invalid version strings
-    self.assertRaises(ValueError, stem.types.get_version, "")
-    self.assertRaises(ValueError, stem.types.get_version, "1.2.3.4nodash")
-    self.assertRaises(ValueError, stem.types.get_version, "1.2.3.a")
-    self.assertRaises(ValueError, stem.types.get_version, "1.2.a.4")
-    self.assertRaises(ValueError, stem.types.get_version, "12.3")
-    self.assertRaises(ValueError, stem.types.get_version, "1.-2.3")
-  
-  def test_comparison(self):
-    """
-    Tests comparision between Version instances.
-    """
-    
-    # check for basic incrementing in each portion
-    self.assert_version_is_greater("1.1.2.3-tag", "0.1.2.3-tag")
-    self.assert_version_is_greater("0.2.2.3-tag", "0.1.2.3-tag")
-    self.assert_version_is_greater("0.1.3.3-tag", "0.1.2.3-tag")
-    self.assert_version_is_greater("0.1.2.4-tag", "0.1.2.3-tag")
-    self.assert_version_is_greater("0.1.2.3-ugg", "0.1.2.3-tag")
-    self.assert_version_is_equal("0.1.2.3-tag", "0.1.2.3-tag")
-    
-    # checks that a missing patch level equals zero
-    self.assert_version_is_equal("0.1.2", "0.1.2.0")
-    self.assert_version_is_equal("0.1.2-tag", "0.1.2.0-tag")
-    
-    # checks for missing patch or status
-    self.assert_version_is_greater("0.1.2.3-tag", "0.1.2.3")
-    self.assert_version_is_greater("0.1.2.3-tag", "0.1.2-tag")
-    self.assert_version_is_greater("0.1.2.3-tag", "0.1.2")
-    
-    self.assert_version_is_equal("0.1.2.3", "0.1.2.3")
-    self.assert_version_is_equal("0.1.2", "0.1.2")
-  
-  def test_string(self):
-    """
-    Tests the Version -> string conversion.
-    """
-    
-    # checks conversion with various numbers of arguments
-    
-    self.assert_string_matches("0.1.2.3-tag")
-    self.assert_string_matches("0.1.2.3")
-    self.assert_string_matches("0.1.2")
-  
-  def assert_versions_match(self, version, major, minor, micro, patch, status):
-    """
-    Asserts that the values for a types.Version instance match the given
-    values.
-    """
-    
-    self.assertEqual(version.major, major)
-    self.assertEqual(version.minor, minor)
-    self.assertEqual(version.micro, micro)
-    self.assertEqual(version.patch, patch)
-    self.assertEqual(version.status, status)
-  
-  def assert_version_is_greater(self, firstVersion, secondVersion):
-    """
-    Asserts that the parsed version of the first version is greate than the
-    second (also checking the inverse).
-    """
-    
-    version1 = stem.types.get_version(firstVersion)
-    version2 = stem.types.get_version(secondVersion)
-    self.assertEqual(version1 > version2, True)
-    self.assertEqual(version1 < version2, False)
-  
-  def assert_version_is_equal(self, firstVersion, secondVersion):
-    """
-    Asserts that the parsed version of the first version equals the second.
-    """
-    
-    version1 = stem.types.get_version(firstVersion)
-    version2 = stem.types.get_version(secondVersion)
-    self.assertEqual(version1, version2)
-  
-  def assert_string_matches(self, version):
-    """
-    Parses the given version string then checks that its string representation
-    matches the input.
-    """
-    
-    self.assertEqual(version, str(stem.types.get_version(version)))
-



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits