tests/test-byteify-strings.t
author Pierre-Yves David <pierre-yves.david@octobus.net>
Tue, 18 Feb 2025 22:24:08 +0100
changeset 52964 469b9a628b51
parent 52339 e39cfc5adcfe
permissions -rw-r--r--
dirstatemap: update, document and type the identity tracking This new form should hopefully be clearer and less error prone.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42686
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
     1
  $ byteify_strings () {
43493
3a463e5e470b tests: quote $PYTHON in test-byteify-strings.t
Matt Harbison <matt_harbison@yahoo.com>
parents: 43407
diff changeset
     2
  >   "$PYTHON" "$TESTDIR/../contrib/byteify-strings.py" "$@"
42686
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
     3
  > }
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
     4
42701
11498aa91c03 byteify-strings: add --version argument
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42700
diff changeset
     5
Test version
11498aa91c03 byteify-strings: add --version argument
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42700
diff changeset
     6
11498aa91c03 byteify-strings: add --version argument
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42700
diff changeset
     7
  $ byteify_strings --version
11498aa91c03 byteify-strings: add --version argument
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42700
diff changeset
     8
  Byteify strings * (glob)
11498aa91c03 byteify-strings: add --version argument
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42700
diff changeset
     9
42686
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    10
Test in-place
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    11
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    12
  $ cat > testfile.py <<EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    13
  > obj['test'] = b"1234"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    14
  > mydict.iteritems()
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    15
  > EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    16
  $ byteify_strings testfile.py -i
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    17
  $ cat testfile.py
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    18
  obj[b'test'] = b"1234"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    19
  mydict.iteritems()
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    20
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    21
Test with dictiter
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    22
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    23
  $ cat > testfile.py <<EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    24
  > obj['test'] = b"1234"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    25
  > mydict.iteritems()
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    26
  > EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    27
  $ byteify_strings testfile.py --dictiter
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    28
  obj[b'test'] = b"1234"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    29
  mydict.items()
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    30
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    31
Test kwargs-like objects
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    32
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    33
  $ cat > testfile.py <<EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    34
  > kwargs['test'] = "123"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    35
  > kwargs[test['testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    36
  > kwargs[test[[['testing']]]]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    37
  > kwargs[kwargs['testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    38
  > kwargs.get('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    39
  > kwargs.pop('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    40
  > kwargs.get('test', 'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    41
  > kwargs.pop('test', 'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    42
  > kwargs.setdefault('test', 'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    43
  > 
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    44
  > opts['test'] = "123"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    45
  > opts[test['testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    46
  > opts[test[[['testing']]]]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    47
  > opts[opts['testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    48
  > opts.get('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    49
  > opts.pop('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    50
  > opts.get('test', 'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    51
  > opts.pop('test', 'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    52
  > opts.setdefault('test', 'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    53
  > 
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    54
  > commitopts['test'] = "123"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    55
  > commitopts[test['testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    56
  > commitopts[test[[['testing']]]]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    57
  > commitopts[commitopts['testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    58
  > commitopts.get('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    59
  > commitopts.pop('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    60
  > commitopts.get('test', 'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    61
  > commitopts.pop('test', 'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    62
  > commitopts.setdefault('test', 'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    63
  > EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    64
  $ 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
    65
  kwargs['test'] = b"123"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    66
  kwargs[test[b'testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    67
  kwargs[test[[[b'testing']]]]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    68
  kwargs[kwargs['testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    69
  kwargs.get('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    70
  kwargs.pop('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    71
  kwargs.get('test', b'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    72
  kwargs.pop('test', b'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    73
  kwargs.setdefault('test', b'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    74
  
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    75
  opts['test'] = b"123"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    76
  opts[test[b'testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    77
  opts[test[[[b'testing']]]]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    78
  opts[opts['testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    79
  opts.get('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    80
  opts.pop('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    81
  opts.get('test', b'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    82
  opts.pop('test', b'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    83
  opts.setdefault('test', b'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    84
  
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    85
  commitopts['test'] = b"123"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    86
  commitopts[test[b'testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    87
  commitopts[test[[[b'testing']]]]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    88
  commitopts[commitopts['testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    89
  commitopts.get('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    90
  commitopts.pop('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    91
  commitopts.get('test', b'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    92
  commitopts.pop('test', b'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    93
  commitopts.setdefault('test', b'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    94
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    95
Test attr*() as methods
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    96
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    97
  $ cat > testfile.py <<EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    98
  > setattr(o, 'a', 1)
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
    99
  > util.setattr(o, 'ae', 1)
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   100
  > util.getattr(o, 'alksjdf', 'default')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   101
  > util.addattr(o, 'asdf')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   102
  > util.hasattr(o, 'lksjdf', 'default')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   103
  > util.safehasattr(o, 'lksjdf', 'default')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   104
  > @eh.wrapfunction(func, '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
  > @eh.wrapclass(klass, 'lksjdf')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   108
  > def f():
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   109
  >     pass
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   110
  > EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   111
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   112
Test without attr*() as methods
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   113
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   114
  $ cat > testfile.py <<EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   115
  > setattr(o, 'a', 1)
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   116
  > util.setattr(o, 'ae', 1)
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   117
  > util.getattr(o, 'alksjdf', 'default')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   118
  > util.addattr(o, 'asdf')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   119
  > util.hasattr(o, 'lksjdf', 'default')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   120
  > util.safehasattr(o, 'lksjdf', 'default')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   121
  > @eh.wrapfunction(func, 'lksjdf')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   122
  > def f():
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   123
  >     pass
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   124
  > @eh.wrapclass(klass, 'lksjdf')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   125
  > def f():
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   126
  >     pass
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   127
  > EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   128
  $ byteify_strings testfile.py
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   129
  setattr(o, 'a', 1)
50770
8250ecb53f30 byteify-strings: passe sysstr to attr function and wrapper
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43493
diff changeset
   130
  util.setattr(o, 'ae', 1)
8250ecb53f30 byteify-strings: passe sysstr to attr function and wrapper
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43493
diff changeset
   131
  util.getattr(o, 'alksjdf', b'default')
8250ecb53f30 byteify-strings: passe sysstr to attr function and wrapper
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43493
diff changeset
   132
  util.addattr(o, 'asdf')
8250ecb53f30 byteify-strings: passe sysstr to attr function and wrapper
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43493
diff changeset
   133
  util.hasattr(o, 'lksjdf', b'default')
8250ecb53f30 byteify-strings: passe sysstr to attr function and wrapper
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43493
diff changeset
   134
  util.safehasattr(o, 'lksjdf', b'default')
8250ecb53f30 byteify-strings: passe sysstr to attr function and wrapper
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43493
diff changeset
   135
  @eh.wrapfunction(func, 'lksjdf')
42686
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   136
  def f():
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   137
      pass
50770
8250ecb53f30 byteify-strings: passe sysstr to attr function and wrapper
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43493
diff changeset
   138
  @eh.wrapclass(klass, 'lksjdf')
42686
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   139
  def f():
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   140
      pass
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   141
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   142
Test ignore comments
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   143
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   144
  $ cat > testfile.py <<EOF
42700
f9b64ff9d26b byteify-strings: add space in special comments to silence flake8 error
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42687
diff changeset
   145
  > # py3-transform: off
42686
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   146
  > "none"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   147
  > "of"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   148
  > 'these'
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   149
  > s = """should"""
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   150
  > d = '''be'''
42700
f9b64ff9d26b byteify-strings: add space in special comments to silence flake8 error
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42687
diff changeset
   151
  > # py3-transform: on
42686
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   152
  > "this should"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   153
  > 'and this also'
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   154
  > 
42700
f9b64ff9d26b byteify-strings: add space in special comments to silence flake8 error
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42687
diff changeset
   155
  > # no-py3-transform
42686
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   156
  > l = "this should be ignored"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   157
  > l2 = "this shouldn't"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   158
  > 
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   159
  > EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   160
  $ byteify_strings testfile.py
42700
f9b64ff9d26b byteify-strings: add space in special comments to silence flake8 error
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42687
diff changeset
   161
  # py3-transform: off
42686
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   162
  "none"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   163
  "of"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   164
  'these'
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   165
  s = """should"""
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   166
  d = '''be'''
42700
f9b64ff9d26b byteify-strings: add space in special comments to silence flake8 error
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42687
diff changeset
   167
  # py3-transform: on
42686
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   168
  b"this should"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   169
  b'and this also'
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   170
  
42700
f9b64ff9d26b byteify-strings: add space in special comments to silence flake8 error
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42687
diff changeset
   171
  # no-py3-transform
42686
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   172
  l = "this should be ignored"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   173
  l2 = b"this shouldn't"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   174
  
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   175
Test triple-quoted strings
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   176
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   177
  $ cat > testfile.py <<EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   178
  > """This is ignored
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   179
  > """
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
  > line = """
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   182
  >   This should not be
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   183
  > """
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   184
  > line = '''
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   185
  > Neither should this
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
  > EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   188
  $ byteify_strings testfile.py
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   189
  """This is ignored
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
  
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   192
  line = b"""
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   193
    This should not be
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   194
  """
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   195
  line = b'''
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   196
  Neither should this
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   197
  '''
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   198
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   199
Test prefixed strings
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
  $ cat > testfile.py <<EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   202
  > obj['test'] = b"1234"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   203
  > obj[r'test'] = u"1234"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   204
  > EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   205
  $ byteify_strings testfile.py
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   206
  obj[b'test'] = b"1234"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
   207
  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
   208
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   209
Test multi-line alignment
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   210
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   211
  $ cat > testfile.py <<'EOF'
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   212
  > def foo():
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   213
  >     error.Abort(_("foo"
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   214
  >                  "bar"
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   215
  >                  "%s")
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   216
  >                % parameter)
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   217
  > {
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   218
  >     'test': dict,
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   219
  >     'test2': dict,
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
  > [
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   222
  >    "thing",
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   223
  >    "thing2"
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   224
  > ]
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   225
  > (
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   226
  >    "tuple",
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   227
  >    "tuple2",
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   228
  > )
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   229
  > {"thing",
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
  > EOF
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   232
  $ byteify_strings testfile.py
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   233
  def foo():
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   234
      error.Abort(_(b"foo"
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   235
                    b"bar"
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   236
                    b"%s")
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   237
                  % parameter)
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
      b'test': dict,
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   240
      b'test2': dict,
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   241
  }
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   242
  [
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   243
     b"thing",
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   244
     b"thing2"
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   245
  ]
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   246
  (
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   247
     b"tuple",
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   248
     b"tuple2",
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   249
  )
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   250
  {b"thing",
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42686
diff changeset
   251
   }