1 """Tests basic git operations: commit, log, config"""
2 # pylint: disable=redefined-outer-name
3 from __future__
import absolute_import
, division
, unicode_literals
6 # NOTE: run_in_tmpdir is required by pytest even though it is only used indirectly.
7 from .helper
import run_in_tmpdir
8 from .helper
import app_context
11 # These assertions make flake8 happy. It considers them unused imports otherwise.
12 assert run_in_tmpdir
is not None
13 assert app_context
is not None
16 def test_git_commit(app_context
):
17 """Test running 'git commit' via cola.git"""
18 helper
.write_file('A', 'A')
19 helper
.write_file('B', 'B')
20 helper
.run_git('add', 'A', 'B')
22 app_context
.git
.commit(m
='initial commit')
23 log
= helper
.run_git('-c', 'log.showsignature=false', 'log', '--pretty=oneline')
26 actual
= len(log
.splitlines())
27 assert expect
== actual
30 def test_git_config(app_context
):
31 """Test cola.git.config()"""
32 helper
.run_git('config', 'section.key', 'value')
33 expect
= (0, 'value', '')
34 actual
= app_context
.git
.config('section.key', get
=True)
35 assert expect
== actual