def test_null(self):
self.writerAssertEqual([], '')
- def test_single(self):
+ def test_single_writer(self):
self.writerAssertEqual([['abc']], 'abc\r\n')
- def test_simple(self):
+ def test_simple_writer(self):
self.writerAssertEqual([[1, 2, 'abc', 3, 4]], '1,2,abc,3,4\r\n')
def test_quotes(self):
check('\nfoo', 'foo*', False)
check('\n', '*')
+ def test_fnmatchcase(self):
+ check = self.check_match
+ check('AbC', 'abc', 0)
+ check('abc', 'AbC', 0)
+
def test_main():
test_support.run_unittest(FnmatchTestCase)
self.assertRaises(TypeError, setattr, p, 'args', (1, 2))
self.assertRaises(TypeError, setattr, p, 'keywords', dict(a=1, b=2))
+ p = self.thetype(hex)
+ try:
+ del p.__dict__
+ except TypeError:
+ pass
+ else:
+ self.fail('partial object allowed __dict__ to be deleted')
+
def test_argument_checking(self):
self.assertRaises(TypeError, self.thetype) # need at least a func arg
try:
self.assertRaises(ZeroDivisionError, self.thetype(f), 1, 0)
self.assertRaises(ZeroDivisionError, self.thetype(f, y=0), 1)
- def test_attributes(self):
- p = self.thetype(hex)
- try:
- del p.__dict__
- except TypeError:
- pass
- else:
- self.fail('partial object allowed __dict__ to be deleted')
-
def test_weakref(self):
f = self.thetype(int, base=16)
p = proxy(f)
return int(value)
else:
return int(value[:-1]) * _time_units[value[-1]]
- except ValueError, IndexError:
+ except (ValueError, IndexError):
raise OptionValueError(
'option %s: invalid duration: %r' % (opt, value))
s = Template('$who likes $100')
raises(ValueError, s.substitute, dict(who='tim'))
- def test_delimiter_override(self):
- class PieDelims(Template):
- delimiter = '@'
- s = PieDelims('@who likes to eat a bag of @{what} worth $100')
- self.assertEqual(s.substitute(dict(who='tim', what='ham')),
- 'tim likes to eat a bag of ham worth $100')
-
def test_idpattern_override(self):
class PathPattern(Template):
idpattern = r'[_a-z][._a-z0-9]*'
raises(ValueError, s.substitute, dict(gift='bud', who='you'))
eq(s.safe_substitute(), 'this &gift is for &{who} &')
+ class PieDelims(Template):
+ delimiter = '@'
+ s = PieDelims('@who likes to eat a bag of @{what} worth $100')
+ self.assertEqual(s.substitute(dict(who='tim', what='ham')),
+ 'tim likes to eat a bag of ham worth $100')
+
def test_main():
from test import test_support