author | David Douard <david.douard@logilab.fr> |
Thu, 02 Jul 2015 19:54:25 +0200 | |
changeset 10496 | e95b559a06a2 |
parent 5424 | 8ecbcbff9777 |
child 10614 | 57dfde80df11 |
permissions | -rw-r--r-- |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
1 |
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
3 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
4 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
5 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
9 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
14 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
15 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
18 |
""" |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
19 |
|
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
20 |
""" |
0 | 21 |
from logilab.common.testlib import TestCase, unittest_main |
22 |
||
23 |
import cubicwebfs |
|
24 |
import sre |
|
25 |
||
26 |
def spec_parser(filename) : |
|
27 |
""" |
|
28 |
extract tests from specification |
|
29 |
""" |
|
30 |
sections = [] |
|
31 |
buffer = "" |
|
32 |
in_section = False |
|
33 |
for line in file(filename) : |
|
34 |
if line.startswith('Test::'): |
|
35 |
in_section = True |
|
36 |
buffer = "" |
|
37 |
elif in_section : |
|
38 |
if line.startswith(" ") or not line.strip() : |
|
39 |
buffer += line.lstrip() |
|
40 |
else : |
|
41 |
sections.append(buffer) |
|
42 |
in_section = False |
|
43 |
tests = [] |
|
44 |
for section in sections : |
|
45 |
subsections = [t for t in section.strip().split('$ ls') if t] |
|
46 |
for subsection in subsections : |
|
47 |
path, results = subsection.splitlines()[0], subsection.splitlines()[1:] |
|
48 |
path = path.strip() |
|
49 |
items = set([i for i in sre.split('[\t\n]', '\n'.join(results)) if i]) |
|
50 |
tests.append((path, items)) |
|
51 |
return tests |
|
52 |
||
53 |
tests = spec_parser("cubicwebfs-spec.txt") |
|
54 |
||
55 |
class monTC(TestCase) : |
|
56 |
pass |
|
57 |
||
58 |
for index, (path, results) in enumerate(tests) : |
|
59 |
def f(self, p=path, r=results) : |
|
60 |
res = set(cubicwebfs.ls(p)) |
|
61 |
self.assertEqual(r, res) #, 'en trop %s\nmanque %s' % (r-results,results-r)) |
|
62 |
f.__doc__ = "%s %s"%(index,path) |
|
63 |
setattr(monTC,'test_%s'%index,f) |
|
64 |
||
65 |
if __name__ == '__main__': |
|
66 |
unittest_main() |