##// END OF EJS Templates
histedit: make verification configurable...
histedit: make verification configurable Before we can add a 'base' action to histedit need to change verification so that action can specify which steps of verification should run for it. Also it's everything we need for the exec and stop actions implementation. I thought about baking verification into each histedit action (so each of them is responsible for verifying its constraints) but it felt wrong because: - every action would need to know its context (eg. the list of all other actions) - a lot of duplicated work will be added - each action will iterate through all others - the steps of the verification would need to be extracted and named anyway in order to be reused The verifyrules function grows too big now. I plan to refator it in one of the next series.

File last commit:

r18666:fb9d1c28 default
r27082:4898e442 default
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__)