Commits

Ronny Pfannschmidt committed c5ee6c7

files test + output

  • Participants
  • Parent commits a84d539

Comments (0)

Files changed (2)

File mergegettext.py

+import argparse
 from mercurial import simplemerge
 Merge3Text = simplemerge.Merge3Text
 
     )
     return ''.join(lines)
 
+def readfile(name):
+    with open(name) as fp:
+        return fp.read()
 
+def files(base, local, other):
+    base_data = readfile(base)
+    local_data = readfile(local)
+    other_data = readfile(other)
+
+    result = simple(base_data, local_data, other_data)
+
+    with open(local, 'w') as fp:
+        fp.write(result)
+
+
+
+parser = argparse.ArgumentParser()
+parser.add_argument('base')
+parser.add_argument('local')
+parser.add_argument('other')
+
+def main(args=None):
+    opts = parser.parse_args(args)
+    print opts
+    files(opts.base, opts.local, opts.other)
+
+if __name__ == '__main__':
+    main()

File test_simple.py

-from mergegettext import simple
+from mergegettext import simple, files
 
 
 BASE="""
 
 def test_simple():
     assert simple(BASE, LOCAL, OTHER) == OTHER
+
+
+def test_files(tmpdir, monkeypatch):
+    tmpdir.join('base').write(BASE)
+    tmpdir.join('local').write(LOCAL)
+    tmpdir.join('other').write(OTHER)
+
+    monkeypatch.chdir(tmpdir)
+    files('base', 'local', 'other')
+    result = tmpdir.join('local').read()
+    assert result == OTHER
+