@@ -259,7 +259,7 @@ def test_extend_on_object(self):
259
259
self .assertEqual (len (new .enabled_rules (None )), 2 )
260
260
261
261
def test_extend_on_file (self ):
262
- with tempfile .NamedTemporaryFile ('w' ) as f :
262
+ with tempfile .NamedTemporaryFile ('w' , encoding = 'utf_8' ) as f :
263
263
f .write ('rules:\n '
264
264
' colons:\n '
265
265
' max-spaces-before: 0\n '
@@ -278,7 +278,7 @@ def test_extend_on_file(self):
278
278
self .assertEqual (len (c .enabled_rules (None )), 2 )
279
279
280
280
def test_extend_remove_rule (self ):
281
- with tempfile .NamedTemporaryFile ('w' ) as f :
281
+ with tempfile .NamedTemporaryFile ('w' , encoding = 'utf_8' ) as f :
282
282
f .write ('rules:\n '
283
283
' colons:\n '
284
284
' max-spaces-before: 0\n '
@@ -297,7 +297,7 @@ def test_extend_remove_rule(self):
297
297
self .assertEqual (len (c .enabled_rules (None )), 1 )
298
298
299
299
def test_extend_edit_rule (self ):
300
- with tempfile .NamedTemporaryFile ('w' ) as f :
300
+ with tempfile .NamedTemporaryFile ('w' , encoding = 'utf_8' ) as f :
301
301
f .write ('rules:\n '
302
302
' colons:\n '
303
303
' max-spaces-before: 0\n '
@@ -319,7 +319,7 @@ def test_extend_edit_rule(self):
319
319
self .assertEqual (len (c .enabled_rules (None )), 2 )
320
320
321
321
def test_extend_reenable_rule (self ):
322
- with tempfile .NamedTemporaryFile ('w' ) as f :
322
+ with tempfile .NamedTemporaryFile ('w' , encoding = 'utf_8' ) as f :
323
323
f .write ('rules:\n '
324
324
' colons:\n '
325
325
' max-spaces-before: 0\n '
@@ -339,7 +339,7 @@ def test_extend_reenable_rule(self):
339
339
self .assertEqual (len (c .enabled_rules (None )), 2 )
340
340
341
341
def test_extend_recursive_default_values (self ):
342
- with tempfile .NamedTemporaryFile ('w' ) as f :
342
+ with tempfile .NamedTemporaryFile ('w' , encoding = 'utf_8' ) as f :
343
343
f .write ('rules:\n '
344
344
' braces:\n '
345
345
' max-spaces-inside: 1248\n ' )
@@ -354,7 +354,7 @@ def test_extend_recursive_default_values(self):
354
354
self .assertEqual (c .rules ['braces' ]['min-spaces-inside-empty' ], 2357 )
355
355
self .assertEqual (c .rules ['braces' ]['max-spaces-inside-empty' ], - 1 )
356
356
357
- with tempfile .NamedTemporaryFile ('w' ) as f :
357
+ with tempfile .NamedTemporaryFile ('w' , encoding = 'utf_8' ) as f :
358
358
f .write ('rules:\n '
359
359
' colons:\n '
360
360
' max-spaces-before: 1337\n ' )
@@ -366,8 +366,8 @@ def test_extend_recursive_default_values(self):
366
366
self .assertEqual (c .rules ['colons' ]['max-spaces-before' ], 1337 )
367
367
self .assertEqual (c .rules ['colons' ]['max-spaces-after' ], 1 )
368
368
369
- with tempfile .NamedTemporaryFile ('w' ) as f1 , \
370
- tempfile .NamedTemporaryFile ('w' ) as f2 :
369
+ with tempfile .NamedTemporaryFile ('w' , encoding = 'utf_8' ) as f1 , \
370
+ tempfile .NamedTemporaryFile ('w' , encoding = 'utf_8' ) as f2 :
371
371
f1 .write ('rules:\n '
372
372
' colons:\n '
373
373
' max-spaces-before: 1337\n ' )
@@ -384,7 +384,7 @@ def test_extend_recursive_default_values(self):
384
384
self .assertEqual (c .rules ['colons' ]['max-spaces-after' ], 1 )
385
385
386
386
def test_extended_ignore_str (self ):
387
- with tempfile .NamedTemporaryFile ('w' ) as f :
387
+ with tempfile .NamedTemporaryFile ('w' , encoding = 'utf_8' ) as f :
388
388
f .write ('ignore: |\n '
389
389
' *.template.yaml\n ' )
390
390
f .flush ()
@@ -394,7 +394,7 @@ def test_extended_ignore_str(self):
394
394
self .assertEqual (c .ignore .match_file ('test.yaml' ), False )
395
395
396
396
def test_extended_ignore_list (self ):
397
- with tempfile .NamedTemporaryFile ('w' ) as f :
397
+ with tempfile .NamedTemporaryFile ('w' , encoding = 'utf_8' ) as f :
398
398
f .write ('ignore:\n '
399
399
' - "*.template.yaml"\n ' )
400
400
f .flush ()
@@ -564,7 +564,8 @@ def test_no_ignore(self):
564
564
)))
565
565
566
566
def test_run_with_ignore_str (self ):
567
- with open (os .path .join (self .wd , '.yamllint' ), 'w' ) as f :
567
+ path = os .path .join (self .wd , '.yamllint' )
568
+ with open (path , 'w' , encoding = 'utf_8' ) as f :
568
569
f .write ('extends: default\n '
569
570
'ignore: |\n '
570
571
' *.dont-lint-me.yaml\n '
@@ -618,7 +619,8 @@ def test_run_with_ignore_str(self):
618
619
)))
619
620
620
621
def test_run_with_ignore_list (self ):
621
- with open (os .path .join (self .wd , '.yamllint' ), 'w' ) as f :
622
+ path = os .path .join (self .wd , '.yamllint' )
623
+ with open (path , 'w' , encoding = 'utf_8' ) as f :
622
624
f .write ('extends: default\n '
623
625
'ignore:\n '
624
626
' - "*.dont-lint-me.yaml"\n '
@@ -672,19 +674,22 @@ def test_run_with_ignore_list(self):
672
674
)))
673
675
674
676
def test_run_with_ignore_from_file (self ):
675
- with open (os .path .join (self .wd , '.yamllint' ), 'w' ) as f :
677
+ path = os .path .join (self .wd , '.yamllint' )
678
+ with open (path , 'w' , encoding = 'utf_8' ) as f :
676
679
f .write ('extends: default\n '
677
680
'ignore-from-file: .gitignore\n '
678
681
'rules:\n '
679
682
' key-duplicates:\n '
680
683
' ignore-from-file: .ignore-key-duplicates\n ' )
681
684
682
- with open (os .path .join (self .wd , '.gitignore' ), 'w' ) as f :
685
+ path = os .path .join (self .wd , '.gitignore' )
686
+ with open (path , 'w' , encoding = 'utf_8' ) as f :
683
687
f .write ('*.dont-lint-me.yaml\n '
684
688
'/bin/\n '
685
689
'!/bin/*.lint-me-anyway.yaml\n ' )
686
690
687
- with open (os .path .join (self .wd , '.ignore-key-duplicates' ), 'w' ) as f :
691
+ path = os .path .join (self .wd , '.ignore-key-duplicates' )
692
+ with open (path , 'w' , encoding = 'utf_8' ) as f :
688
693
f .write ('/ign-dup\n ' )
689
694
690
695
sys .stdout = StringIO ()
@@ -729,13 +734,16 @@ def test_run_with_ignore_from_file(self):
729
734
)))
730
735
731
736
def test_run_with_ignored_from_file (self ):
732
- with open (os .path .join (self .wd , '.yamllint' ), 'w' ) as f :
737
+ path = os .path .join (self .wd , '.yamllint' )
738
+ with open (path , 'w' , encoding = 'utf_8' ) as f :
733
739
f .write ('ignore-from-file: [.gitignore, .yamlignore]\n '
734
740
'extends: default\n ' )
735
- with open (os .path .join (self .wd , '.gitignore' ), 'w' ) as f :
741
+ path = os .path .join (self .wd , '.gitignore' )
742
+ with open (path , 'w' , encoding = 'utf_8' ) as f :
736
743
f .write ('*.dont-lint-me.yaml\n '
737
744
'/bin/\n ' )
738
- with open (os .path .join (self .wd , '.yamlignore' ), 'w' ) as f :
745
+ path = os .path .join (self .wd , '.yamlignore' )
746
+ with open (path , 'w' , encoding = 'utf_8' ) as f :
739
747
f .write ('!/bin/*.lint-me-anyway.yaml\n ' )
740
748
741
749
sys .stdout = StringIO ()
@@ -794,7 +802,7 @@ def test_run_with_ignore_with_broken_symlink(self):
794
802
cli .run (('-f' , 'parsable' , '.' ))
795
803
self .assertNotEqual (ctx .returncode , 0 )
796
804
797
- with open (os .path .join (wd , '.yamllint' ), 'w' ) as f :
805
+ with open (os .path .join (wd , '.yamllint' ), 'w' , encoding = 'utf_8' ) as f :
798
806
f .write ('extends: default\n '
799
807
'ignore: |\n '
800
808
' *404.yaml\n ' )
@@ -812,7 +820,8 @@ def test_run_with_ignore_with_broken_symlink(self):
812
820
shutil .rmtree (wd )
813
821
814
822
def test_run_with_ignore_on_ignored_file (self ):
815
- with open (os .path .join (self .wd , '.yamllint' ), 'w' ) as f :
823
+ path = os .path .join (self .wd , '.yamllint' )
824
+ with open (path , 'w' , encoding = 'utf_8' ) as f :
816
825
f .write ('ignore: file.dont-lint-me.yaml\n '
817
826
'rules:\n '
818
827
' trailing-spaces: enable\n '
0 commit comments