forked from jakubopatowski/wolverine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_tools.py
48 lines (41 loc) · 1.39 KB
/
test_tools.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import os
import unittest
import tools
import re
class TestTools(unittest.TestCase):
def test_change_rel_path(self):
self.assertEqual(
tools.change_rel_path(
'/home/jopa/Projekty/wolverine/',
'/home/jopa/Projekty/banshee/',
'../banshee/main.cpp'), 'main.cpp')
self.assertEqual(
tools.change_rel_path(
'/home/jopa/Projekty/banshee/',
'/home/jopa/Projekty/barracuda/',
'../wolverine/main.cpp'),
os.path.join('..', 'wolverine', 'main.cpp'))
self.assertEqual(
tools.change_rel_path(
'/home/jopa/Projekty/banshee/makedir/',
'/home/jopa/Projekty/barracuda/',
'../../main.cpp'),
os.path.join('..', 'main.cpp'))
def test_get_files(self):
exclude = ['.ccls-cache']
files = tools.get_files(
'c:/Projekty/trunk/src/radosc',
re.compile(r'\w*.(h|hpp)$'),
exclude,
True)
for item in files:
print(item)
def test_path_leaf(self):
self.assertEqual(
tools.path_leaf('a/b/c'), 'c')
self.assertEqual(
tools.path_leaf('a/b/c//'), 'c')
self.assertEqual(
tools.path_leaf('c:\a\b\c.lib'), 'c.lib')
if __name__ == '__main__':
unittest.main()