Debian Codegraph @

tests/t50_methods.py

raw symbols SCIP
1 # -*- coding: utf-8 -*-
2 import common
3 from common import setup_module, teardown_module
4 from __main__ import py
5
6 import os, sys
7 input_name = '%s/../COPYING' % os.path.dirname(sys.argv[0])
8 with open(input_name) as f:
9 input = f.read()
10
11 def test_1():
12 # No step at all.
13 yield validate, 'texte..texte'
14
15 # One single step.
16 yield validate, 'latin1..ibmpc/'
17
18 # One single step and a surface
19 yield validate, 'latin1..ibmpc'
20
21 # One single step.
22 yield validate, 'texte..latin1'
23
24 # Two single steps.
25 yield validate, 'texte..bangbang'
26
27 # Two single steps and a surface.
28 yield validate, 'texte..ibmpc'
29
30 # Three single steps.
31 yield validate, 'texte..iconqnx'
32
33 # Four single steps, optimized into three (with iconv) or two (without).
34 yield validate, 'ascii-bs..ebcdic'
35
36 def validate(request):
37 before, after = request.split('..')
38
39 # With a pipe
40 if os.name == 'nt':
41 py.test.skip()
42 command = ('$R --quiet --force < %s %s'
43 '| $R --quiet --force %s..%s'
44 % (input_name, request, after, before))
45 print(command)
46 output = common.external_output(command)
47 common.assert_or_diff(output, input)
48
49 # With an intermediate file
50 with open(common.run.work, 'w') as f:
51 f.write(input)
52 command1 = ('$R --quiet --force %s %s'
53 % (request, common.run.work))
54 command2 = ('$R --quiet --force %s..%s %s'
55 % (after, before, common.run.work))
56 print(command1)
57 print(command2)
58 common.external_output(command1)
59 common.external_output(command2)
60 with open(common.run.work) as f:
61 output = f.read()
62 common.assert_or_diff(output, input)