Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(681)

Side by Side Diff: tools/telemetry/third_party/rope/ropetest/contrib/changestacktest.py

Issue 1132103009: Example of refactoring using rope library. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 import unittest
2
3 import rope.base.history
4 import rope.contrib.changestack
5 import rope.base.change
6 from ropetest import testutils
7
8
9 class ChangeStackTest(unittest.TestCase):
10
11 def setUp(self):
12 super(ChangeStackTest, self).setUp()
13 self.project = testutils.sample_project()
14
15 def tearDown(self):
16 testutils.remove_project(self.project)
17 super(ChangeStackTest, self).tearDown()
18
19 def test_change_stack(self):
20 myfile = self.project.root.create_file('myfile.txt')
21 myfile.write('1')
22 stack = rope.contrib.changestack.ChangeStack(self.project)
23 stack.push(rope.base.change.ChangeContents(myfile, '2'))
24 self.assertEquals('2', myfile.read())
25 stack.push(rope.base.change.ChangeContents(myfile, '3'))
26 self.assertEquals('3', myfile.read())
27 stack.pop_all()
28 self.assertEquals('1', myfile.read())
29 changes = stack.merged()
30 self.project.do(changes)
31 self.assertEquals('3', myfile.read())
32
33
34 if __name__ == '__main__':
35 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698