File tree Expand file tree Collapse file tree 5 files changed +7
-7
lines changed
Expand file tree Collapse file tree 5 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ def collect(self):
1212 # We need a yaml parser, e.g. PyYAML.
1313 import yaml
1414
15- raw = yaml .safe_load (self .path .open ())
15+ raw = yaml .safe_load (self .path .open (encoding = "utf-8" ))
1616 for name , spec in sorted (raw .items ()):
1717 yield YamlItem .from_parent (self , name = name , spec = spec )
1818
Original file line number Diff line number Diff line change @@ -817,7 +817,7 @@ case we just write some information out to a ``failures`` file:
817817 # we only look at actual failing test calls, not setup/teardown
818818 if rep.when == " call" and rep.failed:
819819 mode = " a" if os.path.exists(" failures" ) else " w"
820- with open (" failures" , mode) as f:
820+ with open (" failures" , mode, encoding = " utf-8 " ) as f:
821821 # let's also access a fixture for the fun of it
822822 if " tmp_path" in item.fixturenames:
823823 extra = " ({} )" .format(item.funcargs[" tmp_path" ])
Original file line number Diff line number Diff line change @@ -1698,7 +1698,7 @@ and declare its use in a test module via a ``usefixtures`` marker:
16981698 class TestDirectoryInit :
16991699 def test_cwd_starts_empty (self ):
17001700 assert os.listdir(os.getcwd()) == []
1701- with open (" myfile" , " w" ) as f:
1701+ with open (" myfile" , " w" , encoding = " utf-8 " ) as f:
17021702 f.write(" hello" )
17031703
17041704 def test_cwd_again_starts_empty (self ):
Original file line number Diff line number Diff line change @@ -24,8 +24,8 @@ created in the `base temporary directory`_.
2424 d = tmp_path / " sub"
2525 d.mkdir()
2626 p = d / " hello.txt"
27- p.write_text(CONTENT )
28- assert p.read_text() == CONTENT
27+ p.write_text(CONTENT , encoding = " utf-8 " )
28+ assert p.read_text(encoding = " utf-8 " ) == CONTENT
2929 assert len (list (tmp_path.iterdir())) == 1
3030 assert 0
3131
Original file line number Diff line number Diff line change @@ -207,10 +207,10 @@ creation of a per-test temporary directory:
207207 @pytest.fixture (autouse = True )
208208 def initdir (self , tmp_path , monkeypatch ):
209209 monkeypatch.chdir(tmp_path) # change to pytest-provided temporary directory
210- tmp_path.joinpath(" samplefile.ini" ).write_text(" # testdata" )
210+ tmp_path.joinpath(" samplefile.ini" ).write_text(" # testdata" , encoding = " utf-8 " )
211211
212212 def test_method (self ):
213- with open (" samplefile.ini" ) as f:
213+ with open (" samplefile.ini" , encoding = " utf-8 " ) as f:
214214 s = f.read()
215215 assert " testdata" in s
216216
You can’t perform that action at this time.
0 commit comments