##// END OF EJS Templates
sslutil: don't access message attribute in exception (issue5285)...
sslutil: don't access message attribute in exception (issue5285) I should have ran the entire test suite on Python 2.6. Since the hostname matching tests are implemented in Python (not .t tests), it didn't uncover this warning. I'm not sure why - warnings should be printed regardless. This is possibly a bug in the test runner. But that's for another day...

File last commit:

r29394:6d96658a default
r29460:a7d1532b stable
Show More
test-atomictempfile.py
42 lines | 1.3 KiB | text/x-python | PythonLexer
/ tests / test-atomictempfile.py
Greg Ward
atomictempfile: avoid infinite recursion in __del__()....
r14007 import os
import glob
Idan Kamara
test-atomictempfile: convert to unit test
r18666 import unittest
import silenttestrunner
Greg Ward
atomictempfile: avoid infinite recursion in __del__()....
r14007 from mercurial.util import atomictempfile
Idan Kamara
test-atomictempfile: convert to unit test
r18666 class testatomictempfile(unittest.TestCase):
def test1_simple(self):
if os.path.exists('foo'):
os.remove('foo')
file = atomictempfile('foo')
(dir, basename) = os.path.split(file._tempname)
self.assertFalse(os.path.isfile('foo'))
self.assertTrue(basename in glob.glob('.foo-*'))
Greg Ward
atomictempfile: avoid infinite recursion in __del__()....
r14007
Idan Kamara
test-atomictempfile: convert to unit test
r18666 file.write('argh\n')
file.close()
Greg Ward
atomictempfile: avoid infinite recursion in __del__()....
r14007
Idan Kamara
test-atomictempfile: convert to unit test
r18666 self.assertTrue(os.path.isfile('foo'))
self.assertTrue(basename not in glob.glob('.foo-*'))
Greg Ward
atomictempfile: avoid infinite recursion in __del__()....
r14007
Idan Kamara
test-atomictempfile: convert to unit test
r18666 # discard() removes the temp file without making the write permanent
def test2_discard(self):
if os.path.exists('foo'):
os.remove('foo')
file = atomictempfile('foo')
(dir, basename) = os.path.split(file._tempname)
Greg Ward
atomictempfile: avoid infinite recursion in __del__()....
r14007
Idan Kamara
test-atomictempfile: convert to unit test
r18666 file.write('yo\n')
file.discard()
Greg Ward
atomictempfile: avoid infinite recursion in __del__()....
r14007
Idan Kamara
test-atomictempfile: convert to unit test
r18666 self.assertFalse(os.path.isfile('foo'))
self.assertTrue(basename not in os.listdir('.'))
# if a programmer screws up and passes bad args to atomictempfile, they
# get a plain ordinary TypeError, not infinite recursion
def test3_oops(self):
self.assertRaises(TypeError, atomictempfile)
Greg Ward
atomictempfile: avoid infinite recursion in __del__()....
r14007
if __name__ == '__main__':
Idan Kamara
test-atomictempfile: convert to unit test
r18666 silenttestrunner.main(__name__)