[Python-checkins] r54858 - sandbox/trunk/pep0/TODO sandbox/trunk/pep0/test_pep0.py
brett.cannon
python-checkins at python.org
Wed Apr 18 04:37:26 CEST 2007
Author: brett.cannon
Date: Wed Apr 18 04:37:19 2007
New Revision: 54858
Modified:
sandbox/trunk/pep0/TODO
sandbox/trunk/pep0/test_pep0.py
Log:
Add tests for pep0.parse.consume_pep.
Modified: sandbox/trunk/pep0/TODO
==============================================================================
--- sandbox/trunk/pep0/TODO (original)
+++ sandbox/trunk/pep0/TODO Wed Apr 18 04:37:19 2007
@@ -1,12 +1,9 @@
* Update test_pep0:
- + Group tests for pep0.parse together.
- + Update tests to match current functionality.
-
-* Handle XXX comments:
- + __init__
- + pep
+ + authors
+ output
- + Update test_pep0 to reflect refactoring.
+ + pep
+ + statictext
+
Functionality to add
--------------------
Modified: sandbox/trunk/pep0/test_pep0.py
==============================================================================
--- sandbox/trunk/pep0/test_pep0.py (original)
+++ sandbox/trunk/pep0/test_pep0.py Wed Apr 18 04:37:19 2007
@@ -10,6 +10,20 @@
"""Test pep0.parse ."""
+ def setUp(self):
+ self.num = 42
+ self.path = test_support.TESTFN + str(self.num)
+
+ def tearDown(self):
+ if os.path.exists(self.path):
+ os.unlink(self.path)
+
+ def create_simple_pep(self, num=None):
+ if num is None:
+ num = self.num
+ with open(self.path, 'w') as pep_file:
+ pep_file.write("PEP: %s\n\nBody" % num)
+
def test_split_metadata_single_line(self):
# Test basic use case.
gave_field = "field"
@@ -32,6 +46,27 @@
self.failUnlessEqual(got_field, gave_field)
self.failUnlessEqual(got_data, gave_data)
+ def test_consume_pep_number_field(self):
+ # All PEPs must have a PEP field.
+ self.create_simple_pep()
+ metadata = pep0.parse.consume_pep(self.path)
+ self.failUnless('PEP' in metadata)
+ self.failUnlessEqual(metadata['PEP'], self.num)
+
+ def test_consume_pep_file_name(self):
+ # The PEP number is expected to be in file name.
+ # Testing positive results implicit in other tests of pep0.consume_pep.
+ self.path = test_support.TESTFN
+ assert str(self.num) not in self.path
+ self.create_simple_pep()
+ self.failUnlessRaises(ValueError, pep0.parse.consume_pep, self.path)
+
+ def test_consume_pep_valid_int(self):
+ # The found value of the 'PEP' field is expected to be a valid number.
+ self.create_simple_pep("XXX")
+ self.failUnlessRaises(ValueError, pep0.parse.consume_pep, self.path)
+
+
class HandlerTests(unittest.TestCase):
More information about the Python-checkins
mailing list