-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathtest.py
More file actions
58 lines (48 loc) · 1.94 KB
/
test.py
File metadata and controls
58 lines (48 loc) · 1.94 KB
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
49
50
51
52
53
54
55
56
57
58
# Copyright 2022 The go-python Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
import glob
def norm(vs):
if len(vs) == 0:
return vs
if type(vs[0]) == type(""):
return normStr(vs)
return normBytes(vs)
def normStr(vs):
from os import sep
x = []
for v in vs:
x.append(v.replace('/', sep))
return x
def normBytes(vs):
from os import sep
x = []
for v in vs:
x.append(v.replace(b'/', bytes(sep, encoding="utf-8")))
return x
def assertEqual(x, y):
xx = norm(x)
yy = norm(y)
assert xx == yy, "got: %s, want: %s" % (repr(x), repr(y))
## test strings
assertEqual(glob.glob('*'), ["glob.go", "glob_test.go", "testdata"])
assertEqual(glob.glob('*test*'), ["glob_test.go", "testdata"])
assertEqual(glob.glob('*/test*'), ["testdata/test.py", "testdata/test_golden.txt"])
assertEqual(glob.glob('*/test*_*'), ["testdata/test_golden.txt"])
assertEqual(glob.glob('*/t??t*_*'), ["testdata/test_golden.txt"])
assertEqual(glob.glob('*/t[e]?t*_*'), ["testdata/test_golden.txt"])
assertEqual(glob.glob('*/t[oe]?t*_*'), ["testdata/test_golden.txt"])
assertEqual(glob.glob('*/t[o]?t*_*'), [])
## FIXME(sbinet)
## assertEqual(glob.glob('*/t[!o]?t*_*'), ["testdata/test_golden.txt"])
## test bytes
assertEqual(glob.glob(b'*'), [b"glob.go", b"glob_test.go", b"testdata"])
assertEqual(glob.glob(b'*test*'), [b"glob_test.go", b"testdata"])
assertEqual(glob.glob(b'*/test*'), [b"testdata/test.py", b"testdata/test_golden.txt"])
assertEqual(glob.glob(b'*/test*_*'), [b"testdata/test_golden.txt"])
assertEqual(glob.glob(b'*/t??t*_*'), [b"testdata/test_golden.txt"])
assertEqual(glob.glob(b'*/t[e]?t*_*'), [b"testdata/test_golden.txt"])
assertEqual(glob.glob(b'*/t[oe]?t*_*'), [b"testdata/test_golden.txt"])
assertEqual(glob.glob(b'*/t[o]?t*_*'), [])
## FIXME(sbinet)
## assertEqual(glob.glob(b'*/t[!o]?t*_*'), [b"testdata/test_golden.txt"])