Mercurial > p > roundup > code
comparison test/test_token.py @ 470:9f7320624bc2
Added better tokenising to roundup-admin - handles spaces and stuff.
Can use quoting or backslashes. See the roundup.token pydoc.
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Mon, 31 Dec 2001 05:09:20 +0000 |
| parents | |
| children | 9b910e8d987d |
comparison
equal
deleted
inserted
replaced
| 469:d35e51360175 | 470:9f7320624bc2 |
|---|---|
| 1 # | |
| 2 # Copyright (c) 2001 Richard Jones | |
| 3 # This module is free software, and you may redistribute it and/or modify | |
| 4 # under the same terms as Python, so long as this copyright message and | |
| 5 # disclaimer are retained in their original form. | |
| 6 # | |
| 7 # This module is distributed in the hope that it will be useful, | |
| 8 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
| 10 # | |
| 11 # $Id: test_token.py,v 1.1 2001-12-31 05:09:20 richard Exp $ | |
| 12 | |
| 13 import unittest, time | |
| 14 | |
| 15 from roundup.token import token_split | |
| 16 | |
| 17 class TokenTestCase(unittest.TestCase): | |
| 18 def testValid(self): | |
| 19 l = token_split('hello world') | |
| 20 self.assertEqual(l, ['hello', 'world']) | |
| 21 | |
| 22 def testIgnoreExtraSpace(self): | |
| 23 l = token_split('hello world ') | |
| 24 self.assertEqual(l, ['hello', 'world']) | |
| 25 | |
| 26 def testQuoting(self): | |
| 27 l = token_split('"hello world"') | |
| 28 self.assertEqual(l, ['hello world']) | |
| 29 l = token_split("'hello world'") | |
| 30 self.assertEqual(l, ['hello world']) | |
| 31 | |
| 32 def testEmbedQuote(self): | |
| 33 l = token_split(r'Roch\'e Compaan') | |
| 34 self.assertEqual(l, ["Roch'e", "Compaan"]) | |
| 35 l = token_split('address="1 2 3"') | |
| 36 self.assertEqual(l, ['address=1 2 3']) | |
| 37 | |
| 38 def testEscaping(self): | |
| 39 l = token_split('"Roch\'e" Compaan') | |
| 40 self.assertEqual(l, ["Roch'e", "Compaan"]) | |
| 41 l = token_split(r'hello\ world') | |
| 42 self.assertEqual(l, ['hello world']) | |
| 43 l = token_split(r'\\') | |
| 44 self.assertEqual(l, ['\\']) | |
| 45 l = token_split(r'\n') | |
| 46 self.assertEqual(l, ['\n']) | |
| 47 | |
| 48 def testBadQuote(self): | |
| 49 self.assertRaises(ValueError, token_split, '"hello world') | |
| 50 self.assertRaises(ValueError, token_split, "Roch'e Compaan") | |
| 51 | |
| 52 def suite(): | |
| 53 return unittest.makeSuite(TokenTestCase, 'test') | |
| 54 | |
| 55 | |
| 56 # | |
| 57 # $Log: not supported by cvs2svn $ | |
| 58 # | |
| 59 # | |
| 60 # vim: set filetype=python ts=4 sw=4 et si |
