]> git.phdru.name Git - ppu.git/blob - tests/test_cmp.py
Refactor tests: move common functions to ppu_tu.py
[ppu.git] / tests / test_cmp.py
1 #! /usr/bin/env python
2
3 import os
4 import subprocess
5 import sys
6 from ppu_tu import setup, teardown, find_in_path  # noqa
7
8
9 tmp_dir = None
10
11 test_prog_path = find_in_path('cmp.py')
12 if not test_prog_path:
13     sys.exit("Cannot find cmp.py in %s" % os.environ["PATH"])
14
15
16 def create_file(name, content):
17     with open(name, 'w') as fp:
18         fp.write(content)
19
20
21 def test_cmp_equal():
22     create_file('test1', 'test')
23     create_file('test2', 'test')
24     assert subprocess.call(
25         [sys.executable, test_prog_path, "-i", "test1", "test2"]) == 0
26
27     create_file('test3', 'test3')
28     create_file('test4', 'test4')
29     assert subprocess.call(
30         [sys.executable, test_prog_path, "-i", "test3", "test4"]) == 1