tests/test-byteify-strings.t
author Martin von Zweigbergk <martinvonz@google.com>
Fri, 18 Sep 2020 10:15:13 -0700
changeset 45511 e29cd888fd17
parent 43493 3a463e5e470b
child 50773 8250ecb53f30
permissions -rw-r--r--
rebase: delete unused p1 argument to _concludenode() Unused since a0192a03216d (rebase: remove now unnecessary logic to allow empty commit when branch changes, 2020-07-09). Differential Revision: https://phab.mercurial-scm.org/D9055
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
43407
09234eeae206 contrib: require Python 3.7 for byteify-strings.py
Ian Moody <moz-ian@perix.co.uk>
parents: 43379
diff changeset
     1
#require py37
42686
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 () {
43493
3a463e5e470b tests: quote $PYTHON in test-byteify-strings.t
Matt Harbison <matt_harbison@yahoo.com>
parents: 43407
diff changeset
     4
  >   "$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
     5
  > }
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
     6
42701
11498aa91c03 byteify-strings: add --version argument
Raphaël Gomès <rgomes@octobus.net>
parents: 42700
diff changeset
     7
Test version
11498aa91c03 byteify-strings: add --version argument
Raphaël Gomès <rgomes@octobus.net>
parents: 42700
diff changeset
     8
11498aa91c03 byteify-strings: add --version argument
Raphaël Gomès <rgomes@octobus.net>
parents: 42700
diff changeset
     9
  $ byteify_strings --version
11498aa91c03 byteify-strings: add --version argument
Raphaël Gomès <rgomes@octobus.net>
parents: 42700
diff changeset
    10
  Byteify strings * (glob)
11498aa91c03 byteify-strings: add --version argument
Raphaël Gomès <rgomes@octobus.net>
parents: 42700
diff changeset
    11
42686
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    12
Test in-place
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    13
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    14
  $ cat > testfile.py <<EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    15
  > obj['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
  > EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    18
  $ byteify_strings testfile.py -i
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    19
  $ cat testfile.py
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    20
  obj[b'test'] = b"1234"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    21
  mydict.iteritems()
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
Test with dictiter
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    24
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    25
  $ cat > testfile.py <<EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    26
  > obj['test'] = b"1234"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    27
  > mydict.iteritems()
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    28
  > EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    29
  $ byteify_strings testfile.py --dictiter
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    30
  obj[b'test'] = b"1234"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    31
  mydict.items()
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
Test kwargs-like objects
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    34
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    35
  $ cat > testfile.py <<EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    36
  > kwargs['test'] = "123"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    37
  > kwargs[test['testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    38
  > kwargs[test[[['testing']]]]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    39
  > kwargs[kwargs['testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    40
  > kwargs.get('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    41
  > kwargs.pop('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    42
  > kwargs.get('test', 'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    43
  > kwargs.pop('test', 'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    44
  > kwargs.setdefault('test', 'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    45
  > 
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    46
  > opts['test'] = "123"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    47
  > opts[test['testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    48
  > opts[test[[['testing']]]]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    49
  > opts[opts['testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    50
  > opts.get('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    51
  > opts.pop('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    52
  > opts.get('test', 'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    53
  > opts.pop('test', 'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    54
  > opts.setdefault('test', 'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    55
  > 
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    56
  > commitopts['test'] = "123"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    57
  > commitopts[test['testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    58
  > commitopts[test[[['testing']]]]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    59
  > commitopts[commitopts['testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    60
  > commitopts.get('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    61
  > commitopts.pop('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    62
  > commitopts.get('test', 'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    63
  > commitopts.pop('test', 'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    64
  > commitopts.setdefault('test', 'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    65
  > EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    66
  $ 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
    67
  kwargs['test'] = b"123"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    68
  kwargs[test[b'testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    69
  kwargs[test[[[b'testing']]]]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    70
  kwargs[kwargs['testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    71
  kwargs.get('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    72
  kwargs.pop('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    73
  kwargs.get('test', b'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    74
  kwargs.pop('test', b'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    75
  kwargs.setdefault('test', b'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    76
  
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    77
  opts['test'] = b"123"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    78
  opts[test[b'testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    79
  opts[test[[[b'testing']]]]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    80
  opts[opts['testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    81
  opts.get('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    82
  opts.pop('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    83
  opts.get('test', b'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    84
  opts.pop('test', b'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    85
  opts.setdefault('test', b'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    86
  
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    87
  commitopts['test'] = b"123"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    88
  commitopts[test[b'testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    89
  commitopts[test[[[b'testing']]]]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    90
  commitopts[commitopts['testing']]
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    91
  commitopts.get('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    92
  commitopts.pop('test')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    93
  commitopts.get('test', b'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    94
  commitopts.pop('test', b'testing')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    95
  commitopts.setdefault('test', b'testing')
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
Test attr*() as methods
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    98
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    99
  $ cat > testfile.py <<EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   100
  > setattr(o, 'a', 1)
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   101
  > util.setattr(o, 'ae', 1)
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   102
  > util.getattr(o, 'alksjdf', 'default')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   103
  > util.addattr(o, 'asdf')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   104
  > util.hasattr(o, 'lksjdf', 'default')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   105
  > util.safehasattr(o, 'lksjdf', 'default')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   106
  > @eh.wrapfunction(func, 'lksjdf')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   107
  > def f():
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   108
  >     pass
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   109
  > @eh.wrapclass(klass, 'lksjdf')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   110
  > def f():
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   111
  >     pass
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   112
  > EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   113
  $ 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
   114
  setattr(o, 'a', 1)
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   115
  util.setattr(o, 'ae', 1)
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   116
  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
   117
  util.addattr(o, 'asdf')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   118
  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
   119
  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
   120
  @eh.wrapfunction(func, 'lksjdf')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   121
  def f():
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   122
      pass
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   123
  @eh.wrapclass(klass, 'lksjdf')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   124
  def f():
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   125
      pass
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   126
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   127
Test without attr*() as methods
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   128
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   129
  $ cat > testfile.py <<EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   130
  > setattr(o, 'a', 1)
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   131
  > util.setattr(o, 'ae', 1)
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   132
  > util.getattr(o, 'alksjdf', 'default')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   133
  > util.addattr(o, 'asdf')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   134
  > util.hasattr(o, 'lksjdf', 'default')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   135
  > util.safehasattr(o, 'lksjdf', 'default')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   136
  > @eh.wrapfunction(func, 'lksjdf')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   137
  > def f():
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   138
  >     pass
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   139
  > @eh.wrapclass(klass, 'lksjdf')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   140
  > def f():
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   141
  >     pass
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   142
  > EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   143
  $ byteify_strings testfile.py
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   144
  setattr(o, 'a', 1)
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   145
  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
   146
  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
   147
  util.addattr(o, b'asdf')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   148
  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
   149
  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
   150
  @eh.wrapfunction(func, b'lksjdf')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   151
  def f():
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   152
      pass
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   153
  @eh.wrapclass(klass, b'lksjdf')
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   154
  def f():
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   155
      pass
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   156
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   157
Test ignore comments
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
  $ 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
   160
  > # py3-transform: off
42686
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   161
  > "none"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   162
  > "of"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   163
  > 'these'
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   164
  > s = """should"""
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   165
  > 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
   166
  > # py3-transform: on
42686
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   167
  > "this should"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   168
  > 'and this also'
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   169
  > 
42700
f9b64ff9d26b byteify-strings: add space in special comments to silence flake8 error
Raphaël Gomès <rgomes@octobus.net>
parents: 42687
diff changeset
   170
  > # no-py3-transform
42686
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   171
  > l = "this should be ignored"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   172
  > l2 = "this shouldn't"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   173
  > 
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   174
  > EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   175
  $ 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
   176
  # py3-transform: off
42686
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   177
  "none"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   178
  "of"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   179
  'these'
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   180
  s = """should"""
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   181
  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
   182
  # py3-transform: on
42686
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   183
  b"this should"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   184
  b'and this also'
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   185
  
42700
f9b64ff9d26b byteify-strings: add space in special comments to silence flake8 error
Raphaël Gomès <rgomes@octobus.net>
parents: 42687
diff changeset
   186
  # no-py3-transform
42686
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   187
  l = "this should be ignored"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   188
  l2 = b"this shouldn't"
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
Test triple-quoted strings
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
  $ cat > testfile.py <<EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   193
  > """This is ignored
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
  > 
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   196
  > line = """
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   197
  >   This should not be
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
  > line = '''
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   200
  > Neither should this
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
  > EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   203
  $ byteify_strings testfile.py
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   204
  """This is ignored
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   205
  """
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   206
  
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   207
  line = b"""
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   208
    This should not be
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   209
  """
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   210
  line = b'''
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   211
  Neither should this
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   212
  '''
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   213
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   214
Test prefixed strings
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   215
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   216
  $ cat > testfile.py <<EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   217
  > obj['test'] = b"1234"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   218
  > obj[r'test'] = u"1234"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   219
  > EOF
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   220
  $ byteify_strings testfile.py
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   221
  obj[b'test'] = b"1234"
3364b4da5271 byteify-strings: add test for byteify-strings.py
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   222
  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
   223
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   224
Test multi-line alignment
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
  $ cat > testfile.py <<'EOF'
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   227
  > def foo():
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   228
  >     error.Abort(_("foo"
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   229
  >                  "bar"
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   230
  >                  "%s")
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   231
  >                % parameter)
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   232
  > {
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   233
  >     'test': dict,
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   234
  >     'test2': dict,
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
  > [
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   237
  >    "thing",
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   238
  >    "thing2"
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   239
  > ]
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
  >    "tuple",
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   242
  >    "tuple2",
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   243
  > )
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   244
  > {"thing",
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
  > EOF
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   247
  $ byteify_strings testfile.py
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   248
  def foo():
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   249
      error.Abort(_(b"foo"
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   250
                    b"bar"
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   251
                    b"%s")
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   252
                  % parameter)
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   253
  {
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   254
      b'test': dict,
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   255
      b'test2': dict,
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
  [
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   258
     b"thing",
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   259
     b"thing2"
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   260
  ]
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   261
  (
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   262
     b"tuple",
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   263
     b"tuple2",
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   264
  )
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   265
  {b"thing",
26a31c88e1a5 byteify-strings: fix misalignment with multi-line parenthesis
Raphaël Gomès <rgomes@octobus.net>
parents: 42686
diff changeset
   266
   }