2016-09-19 21:41:01 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
2016-09-29 19:38:23 +00:00
|
|
|
from __future__ import print_function
|
2016-09-19 21:41:01 +00:00
|
|
|
|
|
|
|
"""
|
|
|
|
test_git_lint
|
|
|
|
----------------------------------
|
|
|
|
|
|
|
|
Tests for `git_lint` module.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import pytest
|
2016-09-29 19:38:23 +00:00
|
|
|
import copy
|
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
import subprocess
|
|
|
|
import pprint
|
2016-09-19 21:41:01 +00:00
|
|
|
from git_lint import git_lint
|
|
|
|
|
2016-09-29 19:38:23 +00:00
|
|
|
environment = copy.copy(os.environ)
|
|
|
|
environment.update({
|
|
|
|
'LANG': 'C',
|
|
|
|
'LC_ALL': 'C',
|
|
|
|
'PAGER': 'cat',
|
|
|
|
'TZ': 'UTC',
|
|
|
|
'EDITOR': ':',
|
|
|
|
'GIT_AUTHOR_EMAIL': 'author@example.com',
|
|
|
|
'GIT_AUTHOR_NAME': '"A U Thor"',
|
|
|
|
'GIT_COMMITTER_EMAIL': 'committer@example.com',
|
|
|
|
'GIT_COMMITTER_NAME': '"C O Mitter"',
|
|
|
|
'GIT_MERGE_VERBOSITY': '5',
|
|
|
|
'GIT_MERGE_AUTOEDIT': 'no'
|
|
|
|
})
|
|
|
|
|
|
|
|
for key in ['XDF_CONFIG_HOME', 'GITPERLLIB', 'CDPATH',
|
|
|
|
'GREP_OPTIONS', 'UNZIP']:
|
|
|
|
environment.pop(key, None)
|
|
|
|
|
|
|
|
|
2016-09-19 21:41:01 +00:00
|
|
|
class TestGit_lint(object):
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def setup_class(cls):
|
2016-09-29 19:38:23 +00:00
|
|
|
if os.path.exists('t'):
|
|
|
|
shutil.rmtree('t')
|
|
|
|
os.mkdir('t')
|
|
|
|
shutil.copy('.git-lint', 't')
|
|
|
|
os.chdir('t')
|
|
|
|
subprocess.check_output('git init', shell=True, env=environment)
|
|
|
|
|
2016-09-19 21:41:01 +00:00
|
|
|
|
2016-09-29 19:38:23 +00:00
|
|
|
def test_itruns(self):
|
|
|
|
ret = subprocess.check_output('git lint -v', shell=True, env=environment)
|
|
|
|
assert ret.startswith('git-lint')
|
2016-09-19 21:41:01 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def teardown_class(cls):
|
2016-09-29 19:38:23 +00:00
|
|
|
os.chdir('..')
|
|
|
|
shutil.rmtree('t')
|
2016-09-19 21:41:01 +00:00
|
|
|
|