Author: Ronan Lamy <ronan.l...@gmail.com> Branch: testing-cleanup-py3k Changeset: r85133:0814a8d50e58 Date: 2016-06-13 16:30 +0100 http://bitbucket.org/pypy/pypy/changeset/0814a8d50e58/
Log: Don't attempt to modify sys.filesystemencoding; skip tests instead if it's not good enough diff --git a/pypy/module/posix/test/test_posix2.py b/pypy/module/posix/test/test_posix2.py --- a/pypy/module/posix/test/test_posix2.py +++ b/pypy/module/posix/test/test_posix2.py @@ -1180,25 +1180,19 @@ res = os.system(cmd) assert res == 0 +@py.test.fixture +def check_fsencoding(space, pytestconfig): + if pytestconfig.getvalue('runappdirect'): + fsencoding = sys.getfilesystemencoding() + else: + fsencoding = space.sys.filesystemencoding + try: + u"ą".encode(fsencoding) + except UnicodeEncodeError: + py.test.skip("encoding not good enough") +@py.test.mark.usefixtures('check_fsencoding') class AppTestPosixUnicode: - def setup_class(cls): - if cls.runappdirect: - # Can't change encoding - try: - u"ą".encode(sys.getfilesystemencoding()) - except UnicodeEncodeError: - py.test.skip("encoding not good enough") - else: - cls.save_fs_encoding = cls.space.sys.filesystemencoding - cls.space.sys.filesystemencoding = "utf-8" - - def teardown_class(cls): - try: - cls.space.sys.filesystemencoding = cls.save_fs_encoding - except AttributeError: - pass - def test_stat_unicode(self): # test that passing unicode would not raise UnicodeDecodeError import posix _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit