@ -24,6 +24,7 @@ import os
import pty
import pty
import shutil
import shutil
import sys
import sys
import tempfile
import unittest
import unittest
from tests . common import build_temp_workspace
from tests . common import build_temp_workspace
@ -286,24 +287,23 @@ class CommandLineTestCase(unittest.TestCase):
self . assertEqual ( ctx . returncode , 1 )
self . assertEqual ( ctx . returncode , 1 )
def test_run_with_user_yamllintrc_config_file ( self ) :
def test_run_with_user_yamllintrc_config_file ( self ) :
config = os . path . join ( self . wd , ' fake-local-config ' )
self . addCleanup ( os . environ . __delitem__ , ' YAMLLINT_CONFIG_FILE ' )
self . addCleanup ( os . remove , config )
self . addCleanup ( os . environ . __delitem__ , ' YAMLLINTRC ' )
os . environ [ ' YAMLLINTRC ' ] = config
with open ( config , ' w ' ) as f :
with tempfile . NamedTemporaryFile ( ' w ' ) as f :
os . environ [ ' YAMLLINT_CONFIG_FILE ' ] = f . name
f . write ( ' rules: { trailing-spaces: disable} ' )
f . write ( ' rules: { trailing-spaces: disable} ' )
f . flush ( )
with RunContext ( self ) as ctx :
cli . run ( ( os . path . join ( self . wd , ' a.yaml ' ) , ) )
self . assertEqual ( ctx . returncode , 0 )
with RunContext ( self ) as ctx :
with tempfile . NamedTemporaryFile ( ' w ' ) as f :
cli . run ( ( os . path . join ( self . wd , ' a.yaml ' ) , ) )
os . environ [ ' YAMLLINT_CONFIG_FILE ' ] = f . name
self . assertEqual ( ctx . returncode , 0 )
with open ( config , ' w ' ) as f :
f . write ( ' rules: { trailing-spaces: enable} ' )
f . write ( ' rules: { trailing-spaces: enable} ' )
f . flush ( )
with RunContext ( self ) as ctx :
with RunContext ( self ) as ctx :
cli . run ( ( os . path . join ( self . wd , ' a.yaml ' ) , ) )
cli . run ( ( os . path . join ( self . wd , ' a.yaml ' ) , ) )
self . assertEqual ( ctx . returncode , 1 )
self . assertEqual ( ctx . returncode , 1 )
def test_run_version ( self ) :
def test_run_version ( self ) :
with RunContext ( self ) as ctx :
with RunContext ( self ) as ctx :