annotate tests/test-byteify-strings.t @ 42687:26a31c88e1a5

byteify-strings: fix misalignment with multi-line parenthesis This improves the current fix to also take into account cases where the last line ended on the opening `(`, `[` or `{` and adds a regression test.
author Raphaël Gomès <rgomes@octobus.net>
date Sun, 04 Aug 2019 22:14:26 +0200
parents 3364b4da5271
children f9b64ff9d26b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
42686
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
1 #require py3
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
2
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
3 $ byteify_strings () {
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
4 > $PYTHON "$TESTDIR/../contrib/byteify-strings.py" "$@"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
5 > }
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
6
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
7 Test in-place
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
8
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
9 $ cat > testfile.py <<EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
10 > obj['test'] = b"1234"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
11 > mydict.iteritems()
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
12 > EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
13 $ byteify_strings testfile.py -i
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
14 $ cat testfile.py
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
15 obj[b'test'] = b"1234"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
16 mydict.iteritems()
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
17
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
18 Test with dictiter
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
19
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
20 $ cat > testfile.py <<EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
21 > obj['test'] = b"1234"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
22 > mydict.iteritems()
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
23 > EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
24 $ byteify_strings testfile.py --dictiter
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
25 obj[b'test'] = b"1234"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
26 mydict.items()
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
27
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
28 Test kwargs-like objects
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
29
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
30 $ cat > testfile.py <<EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
31 > kwargs['test'] = "123"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
32 > kwargs[test['testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
33 > kwargs[test[[['testing']]]]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
34 > kwargs[kwargs['testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
35 > kwargs.get('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
36 > kwargs.pop('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
37 > kwargs.get('test', 'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
38 > kwargs.pop('test', 'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
39 > kwargs.setdefault('test', 'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
40 >
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
41 > opts['test'] = "123"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
42 > opts[test['testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
43 > opts[test[[['testing']]]]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
44 > opts[opts['testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
45 > opts.get('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
46 > opts.pop('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
47 > opts.get('test', 'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
48 > opts.pop('test', 'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
49 > opts.setdefault('test', 'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
50 >
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
51 > commitopts['test'] = "123"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
52 > commitopts[test['testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
53 > commitopts[test[[['testing']]]]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
54 > commitopts[commitopts['testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
55 > commitopts.get('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
56 > commitopts.pop('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
57 > commitopts.get('test', 'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
58 > commitopts.pop('test', 'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
59 > commitopts.setdefault('test', 'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
60 > EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
61 $ byteify_strings testfile.py --treat-as-kwargs kwargs opts commitopts
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
62 kwargs['test'] = b"123"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
63 kwargs[test[b'testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
64 kwargs[test[[[b'testing']]]]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
65 kwargs[kwargs['testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
66 kwargs.get('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
67 kwargs.pop('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
68 kwargs.get('test', b'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
69 kwargs.pop('test', b'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
70 kwargs.setdefault('test', b'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
71
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
72 opts['test'] = b"123"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
73 opts[test[b'testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
74 opts[test[[[b'testing']]]]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
75 opts[opts['testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
76 opts.get('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
77 opts.pop('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
78 opts.get('test', b'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
79 opts.pop('test', b'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
80 opts.setdefault('test', b'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
81
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
82 commitopts['test'] = b"123"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
83 commitopts[test[b'testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
84 commitopts[test[[[b'testing']]]]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
85 commitopts[commitopts['testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
86 commitopts.get('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
87 commitopts.pop('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
88 commitopts.get('test', b'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
89 commitopts.pop('test', b'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
90 commitopts.setdefault('test', b'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
91
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
92 Test attr*() as methods
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
93
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
94 $ cat > testfile.py <<EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
95 > setattr(o, 'a', 1)
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
96 > util.setattr(o, 'ae', 1)
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
97 > util.getattr(o, 'alksjdf', 'default')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
98 > util.addattr(o, 'asdf')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
99 > util.hasattr(o, 'lksjdf', 'default')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
100 > util.safehasattr(o, 'lksjdf', 'default')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
101 > @eh.wrapfunction(func, 'lksjdf')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
102 > def f():
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
103 > pass
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
104 > @eh.wrapclass(klass, 'lksjdf')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
105 > def f():
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
106 > pass
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
107 > EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
108 $ byteify_strings testfile.py --allow-attr-methods
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
109 setattr(o, 'a', 1)
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
110 util.setattr(o, 'ae', 1)
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
111 util.getattr(o, 'alksjdf', b'default')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
112 util.addattr(o, 'asdf')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
113 util.hasattr(o, 'lksjdf', b'default')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
114 util.safehasattr(o, 'lksjdf', b'default')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
115 @eh.wrapfunction(func, 'lksjdf')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
116 def f():
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
117 pass
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
118 @eh.wrapclass(klass, 'lksjdf')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
119 def f():
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
120 pass
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
121
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
122 Test without attr*() as methods
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
123
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
124 $ cat > testfile.py <<EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
125 > setattr(o, 'a', 1)
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
126 > util.setattr(o, 'ae', 1)
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
127 > util.getattr(o, 'alksjdf', 'default')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
128 > util.addattr(o, 'asdf')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
129 > util.hasattr(o, 'lksjdf', 'default')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
130 > util.safehasattr(o, 'lksjdf', 'default')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
131 > @eh.wrapfunction(func, 'lksjdf')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
132 > def f():
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
133 > pass
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
134 > @eh.wrapclass(klass, 'lksjdf')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
135 > def f():
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
136 > pass
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
137 > EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
138 $ byteify_strings testfile.py
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
139 setattr(o, 'a', 1)
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
140 util.setattr(o, b'ae', 1)
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
141 util.getattr(o, b'alksjdf', b'default')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
142 util.addattr(o, b'asdf')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
143 util.hasattr(o, b'lksjdf', b'default')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
144 util.safehasattr(o, b'lksjdf', b'default')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
145 @eh.wrapfunction(func, b'lksjdf')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
146 def f():
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
147 pass
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
148 @eh.wrapclass(klass, b'lksjdf')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
149 def f():
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
150 pass
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
151
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
152 Test ignore comments
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
153
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
154 $ cat > testfile.py <<EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
155 > #py3-transform: off
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
156 > "none"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
157 > "of"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
158 > 'these'
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
159 > s = """should"""
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
160 > d = '''be'''
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
161 > #py3-transform: on
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
162 > "this should"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
163 > 'and this also'
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
164 >
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
165 > #no-py3-transform
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
166 > l = "this should be ignored"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
167 > l2 = "this shouldn't"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
168 >
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
169 > EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
170 $ byteify_strings testfile.py
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
171 #py3-transform: off
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
172 "none"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
173 "of"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
174 'these'
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
175 s = """should"""
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
176 d = '''be'''
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
177 #py3-transform: on
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
178 b"this should"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
179 b'and this also'
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
180
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
181 #no-py3-transform
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
182 l = "this should be ignored"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
183 l2 = b"this shouldn't"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
184
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
185 Test triple-quoted strings
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
186
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
187 $ cat > testfile.py <<EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
188 > """This is ignored
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
189 > """
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
190 >
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
191 > line = """
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
192 > This should not be
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
193 > """
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
194 > line = '''
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
195 > Neither should this
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
196 > '''
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
197 > EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
198 $ byteify_strings testfile.py
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
199 """This is ignored
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
200 """
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
201
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
202 line = b"""
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
203 This should not be
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
204 """
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
205 line = b'''
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
206 Neither should this
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
207 '''
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
208
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
209 Test prefixed strings
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
210
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
211 $ cat > testfile.py <<EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
212 > obj['test'] = b"1234"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
213 > obj[r'test'] = u"1234"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
214 > EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
215 $ byteify_strings testfile.py
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
216 obj[b'test'] = b"1234"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
217 obj[r'test'] = u"1234"
42687
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
218
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
219 Test multi-line alignment
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
220
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
221 $ cat > testfile.py <<'EOF'
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
222 > def foo():
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
223 > error.Abort(_("foo"
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
224 > "bar"
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
225 > "%s")
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
226 > % parameter)
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
227 > {
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
228 > 'test': dict,
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
229 > 'test2': dict,
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
230 > }
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
231 > [
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
232 > "thing",
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
233 > "thing2"
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
234 > ]
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
235 > (
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
236 > "tuple",
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
237 > "tuple2",
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
238 > )
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
239 > {"thing",
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
240 > }
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
241 > EOF
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
242 $ byteify_strings testfile.py
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
243 def foo():
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
244 error.Abort(_(b"foo"
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
245 b"bar"
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
246 b"%s")
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
247 % parameter)
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
248 {
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
249 b'test': dict,
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
250 b'test2': dict,
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
251 }
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
252 [
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
253 b"thing",
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
254 b"thing2"
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
255 ]
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
256 (
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
257 b"tuple",
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
258 b"tuple2",
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
259 )
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
260 {b"thing",
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
261 }