File tree 5 files changed +7
-7
lines changed
5 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ def collect(self):
12
12
# We need a yaml parser, e.g. PyYAML.
13
13
import yaml
14
14
15
- raw = yaml .safe_load (self .path .open ())
15
+ raw = yaml .safe_load (self .path .open (encoding = "utf-8" ))
16
16
for name , spec in sorted (raw .items ()):
17
17
yield YamlItem .from_parent (self , name = name , spec = spec )
18
18
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:
817
817
# we only look at actual failing test calls, not setup/teardown
818
818
if rep.when == " call" and rep.failed:
819
819
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:
821
821
# let's also access a fixture for the fun of it
822
822
if " tmp_path" in item.fixturenames:
823
823
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:
1698
1698
class TestDirectoryInit :
1699
1699
def test_cwd_starts_empty (self ):
1700
1700
assert os.listdir(os.getcwd()) == []
1701
- with open (" myfile" , " w" ) as f:
1701
+ with open (" myfile" , " w" , encoding = " utf-8 " ) as f:
1702
1702
f.write(" hello" )
1703
1703
1704
1704
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`_.
24
24
d = tmp_path / " sub"
25
25
d.mkdir()
26
26
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
29
29
assert len (list (tmp_path.iterdir())) == 1
30
30
assert 0
31
31
Original file line number Diff line number Diff line change @@ -207,10 +207,10 @@ creation of a per-test temporary directory:
207
207
@pytest.fixture (autouse = True )
208
208
def initdir (self , tmp_path , monkeypatch ):
209
209
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 " )
211
211
212
212
def test_method (self ):
213
- with open (" samplefile.ini" ) as f:
213
+ with open (" samplefile.ini" , encoding = " utf-8 " ) as f:
214
214
s = f.read()
215
215
assert " testdata" in s
216
216
You can’t perform that action at this time.
0 commit comments