50
50
class TestWorkingTree(TestCaseInTempDir):
52
52
def test_listfiles(self):
53
branch = Branch.initialize('.')
53
branch = Branch.initialize(u'.')
55
55
print >> open('file', 'w'), "content"
56
56
os.symlink('target', 'symlink')
61
61
self.assertEqual(files[2], ('symlink', '?', 'symlink', None, TreeLink()))
63
63
def test_open_containing(self):
64
branch = Branch.initialize('.')
64
branch = Branch.initialize(u'.')
65
65
wt, relpath = WorkingTree.open_containing()
66
66
self.assertEqual('', relpath)
67
67
self.assertEqual(wt.basedir, branch.base)
68
wt, relpath = WorkingTree.open_containing('.')
68
wt, relpath = WorkingTree.open_containing(u'.')
69
69
self.assertEqual('', relpath)
70
70
self.assertEqual(wt.basedir, branch.base)
71
71
wt, relpath = WorkingTree.open_containing('./foo')
77
77
'file:///' + os.getcwdu())
79
79
def test_construct_with_branch(self):
80
branch = Branch.initialize('.')
80
branch = Branch.initialize(u'.')
81
81
tree = WorkingTree(branch.base, branch)
82
82
self.assertEqual(branch, tree.branch)
83
83
self.assertEqual(branch.base, tree.basedir)
85
85
def test_construct_without_branch(self):
86
branch = Branch.initialize('.')
86
branch = Branch.initialize(u'.')
87
87
tree = WorkingTree(branch.base)
88
88
self.assertEqual(branch.base, tree.branch.base)
89
89
self.assertEqual(branch.base, tree.basedir)
91
91
def test_basic_relpath(self):
92
92
# for comprehensive relpath tests, see whitebox.py.
93
branch = Branch.initialize('.')
93
branch = Branch.initialize(u'.')
94
94
tree = WorkingTree(branch.base)
95
95
self.assertEqual('child',
96
96
tree.relpath(os.path.join(os.getcwd(), 'child')))
98
98
def test_lock_locks_branch(self):
99
branch = Branch.initialize('.')
99
branch = Branch.initialize(u'.')
100
100
tree = WorkingTree(branch.base)
102
102
self.assertEqual(1, tree.branch.control_files._lock_count)
136
136
def test_revert(self):
137
137
"""Test selected-file revert"""
138
b = Branch.initialize('.')
138
b = Branch.initialize(u'.')
140
140
self.build_tree(['hello.txt'])
141
141
file('hello.txt', 'w').write('initial hello')
161
161
self.check_file_contents('hello.txt~', 'new hello')
163
163
def test_unknowns(self):
164
b = Branch.initialize('.')
165
tree = WorkingTree('.', b)
164
b = Branch.initialize(u'.')
165
tree = WorkingTree(u'.', b)
166
166
self.build_tree(['hello.txt',
168
168
self.assertEquals(list(tree.unknowns()),