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

[tor-commits] [stem/master] Unit testing stem.types.ControlLine.pop() examples



commit c0525d58a7e98e2c4b3fa7e2130e69e85aee5247
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sat Nov 5 15:49:48 2011 -0700

    Unit testing stem.types.ControlLine.pop() examples
    
    Adding unit tests and correcting the pydocs for the pop method examples.
---
 run_tests.py                    |    2 +-
 stem/types.py                   |    4 ++--
 test/unit/types/control_line.py |   26 +++++++++++---------------
 3 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/run_tests.py b/run_tests.py
index c0731d9..1228fcc 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -24,7 +24,7 @@ DIVIDER = "=" * 70
 
 # (name, class) tuples for all of our unit and integration tests
 UNIT_TESTS = (("stem.types.ControlMessage", test.unit.types.control_message.TestControlMessage),
-              ("stem.types.ControlLine", test.unit.types.control_line.TestGetEntry),
+              ("stem.types.ControlLine", test.unit.types.control_line.TestControlLine),
               ("stem.types.Version", test.unit.types.version.TestVerion),
              )
 
diff --git a/stem/types.py b/stem/types.py
index b9c21ad..1dc03e2 100644
--- a/stem/types.py
+++ b/stem/types.py
@@ -298,7 +298,7 @@ class ControlLine(str):
     Parses the next space separated entry, removing it and the space from our
     remaining content. Examples...
     
-    >>> line = ControlLine('"We're all mad here." says the grinning cat.')
+    >>> line = ControlLine("\"We're all mad here.\" says the grinning cat.")
     >>> print line.pop(True)
       "We're all mad here."
     >>> print line.pop()
@@ -306,7 +306,7 @@ class ControlLine(str):
     >>> print line.remainder()
       "the grinning cat."
     
-    >>> line = ControlLine('"this has a \\\" and \\\\ in it" foo=bar more_data')
+    >>> line = ControlLine("\"this has a \\\" and \\\\ in it\" foo=bar more_data")
     >>> print line.pop(True, True)
       "this has a \" and \\ in it"
     
diff --git a/test/unit/types/control_line.py b/test/unit/types/control_line.py
index 9c06ab2..d6bda8d 100644
--- a/test/unit/types/control_line.py
+++ b/test/unit/types/control_line.py
@@ -1,29 +1,25 @@
 """
-Unit tests for the types.get_entry function.
+Unit tests for the types.ControlLine class.
 """
 
 import unittest
 import stem.types
 
-class TestGetEntry(unittest.TestCase):
+class TestControlLine(unittest.TestCase):
   """
-  Tests the types.get_entry function.
+  Tests methods of the types.ControlLine class.
   """
   
-  def test_examples(self):
+  def test_pop_examples(self):
     """
-    Checks that the examples from the pydoc are correct.
+    Checks that the pop method's pydoc examples are correct.
     """
     
-    example_input = 'hello there random person'
-    example_result = (None, "hello", "there random person")
-    self.assertEquals(stem.types.get_entry(example_input), example_result)
+    line = stem.types.ControlLine("\"We're all mad here.\" says the grinning cat.")
+    self.assertEquals(line.pop(True), "We're all mad here.")
+    self.assertEquals(line.pop(), "says")
+    self.assertEquals(line.remainder(), "the grinning cat.")
     
-    example_input = 'version="0.1.2.3"'
-    example_result = ("version", "0.1.2.3", "")
-    self.assertEquals(stem.types.get_entry(example_input, True, True), example_result)
-    
-    example_input = r'"this has a \" and \\ in it" foo=bar more_data'
-    example_result = (None, r'this has a " and \ in it', "foo=bar more_data")
-    self.assertEquals(stem.types.get_entry(example_input, False, True, True), example_result)
+    line = stem.types.ControlLine("\"this has a \\\" and \\\\ in it\" foo=bar more_data")
+    self.assertEquals(line.pop(True, True), "this has a \" and \\ in it")
 



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