diff --git a/tests/test-atomictempfile.py b/tests/test-atomictempfile.py index 2cbfb8c497eeeb376e22a7f76db54fb55f931b0a_dGVzdHMvdGVzdC1hdG9taWN0ZW1wZmlsZS5weQ==..fb9d1c2805ff709bf9dc5729791eb62f8b5b2f23_dGVzdHMvdGVzdC1hdG9taWN0ZW1wZmlsZS5weQ== 100644 --- a/tests/test-atomictempfile.py +++ b/tests/test-atomictempfile.py @@ -1,4 +1,7 @@ import os import glob +import unittest +import silenttestrunner + from mercurial.util import atomictempfile @@ -3,11 +6,11 @@ from mercurial.util import atomictempfile -# basic usage -def test1_simple(): - if os.path.exists('foo'): - os.remove('foo') - file = atomictempfile('foo') - (dir, basename) = os.path.split(file._tempname) - assert not os.path.isfile('foo') - assert basename in glob.glob('.foo-*') +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-*')) @@ -13,4 +16,4 @@ - file.write('argh\n') - file.close() + file.write('argh\n') + file.close() @@ -16,5 +19,4 @@ - assert os.path.isfile('foo') - assert basename not in glob.glob('.foo-*') - print 'OK' + self.assertTrue(os.path.isfile('foo')) + self.assertTrue(basename not in glob.glob('.foo-*')) @@ -20,11 +22,8 @@ -# discard() removes the temp file without making the write permanent -def test2_discard(): - if os.path.exists('foo'): - os.remove('foo') - file = atomictempfile('foo') - (dir, basename) = os.path.split(file._tempname) - - file.write('yo\n') - file.discard() + # 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) @@ -30,5 +29,4 @@ - assert not os.path.isfile('foo') - assert basename not in os.listdir('.') - print 'OK' + file.write('yo\n') + file.discard() @@ -34,12 +32,10 @@ -# if a programmer screws up and passes bad args to atomictempfile, they -# get a plain ordinary TypeError, not infinite recursion -def test3_oops(): - try: - file = atomictempfile() - except TypeError: - print "OK" - else: - print "expected TypeError" + 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) if __name__ == '__main__': @@ -44,5 +40,3 @@ if __name__ == '__main__': - test1_simple() - test2_discard() - test3_oops() + silenttestrunner.main(__name__) diff --git a/tests/test-atomictempfile.py.out b/tests/test-atomictempfile.py.out deleted file mode 100644 index 2cbfb8c497eeeb376e22a7f76db54fb55f931b0a_dGVzdHMvdGVzdC1hdG9taWN0ZW1wZmlsZS5weS5vdXQ=..0000000000000000000000000000000000000000 --- a/tests/test-atomictempfile.py.out +++ /dev/null @@ -1,3 +0,0 @@ -OK -OK -OK