[Python-checkins] r54791 - sandbox/trunk/pep0/test_pep0.py
brett.cannon
python-checkins at python.org
Thu Apr 12 23:29:31 CEST 2007
Author: brett.cannon
Date: Thu Apr 12 23:29:29 2007
New Revision: 54791
Modified:
sandbox/trunk/pep0/test_pep0.py
Log:
Refactor author parsing test.
Modified: sandbox/trunk/pep0/test_pep0.py
==============================================================================
--- sandbox/trunk/pep0/test_pep0.py (original)
+++ sandbox/trunk/pep0/test_pep0.py Thu Apr 12 23:29:29 2007
@@ -32,24 +32,22 @@
(got, data, string_rep))
def test_handle_author(self):
- # Handle the various ways authors can be specified:
- # Name <email>,
- # email (name),
- # Name.
- authors = ["Guido van Rossum", "Brett Cannon"]
+ # Handle the various ways authors can be specified.
+ # Test needs to validate not just how the author's name can be written
+ # but also variations in people's names (e.g., 'van', 'Jr.', etc.).
+ authors = ["Guido van Rossum", "Brett Cannon", ]
formats = ["%s <email>", "email (%s)", "%s"]
for format in formats:
- rep = format % authors[0]
- expect = authors[0:1]
- got = pep0.handle_author(rep)
- self.failUnlessEqual(got, expect,
- "%r failed; %r != %r" % (rep, got, expect))
- rep += ', '
- self.failUnlessEqual(pep0.handle_author(rep), expect)
- rep += format % authors[1]
- self.failUnlessEqual(pep0.handle_author(rep), authors)
- rep += ', '
- self.failUnlessEqual(pep0.handle_author(rep), authors)
+ for author_count in range(len(authors)):
+ rep = ', '.join(format % author
+ for author in authors[:author_count+1])
+ expect = authors[:author_count+1]
+ got = pep0.handle_author(rep)
+ self.failUnlessEqual(got, expect)
+ # Test with a trailing comma.
+ rep += ','
+ got = pep0.handle_author(rep)
+ self.failUnlessEqual(got, expect)
class ParseMetaDataTests(unittest.TestCase):
More information about the Python-checkins
mailing list