1 new commit in pytest: https://bitbucket.org/hpk42/pytest/commits/75b0af8a0a2b/ Changeset: 75b0af8a0a2b User: hpk42 Date: 2013-10-21 14:01:02 Summary: fix unicode handling with new monkeypatch.setattr(import_path, value) API. Thanks Rob Dennis. Fixes issue371. Affected #: 3 files
diff -r 0434c999780c14204b60e51eed32d2d0c5c53401 -r 75b0af8a0a2b26a683d51331f6d69088ef18501a CHANGELOG --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,9 @@ Changes between 2.4.2 and 2.4.3 ----------------------------------- +- fix unicode handling with new monkeypatch.setattr(import_path, value) + API. Thanks Rob Dennis. Fixes issue371. + - In assertion rewriting mode on Python 2, fix the detection of coding cookies. See issue #330. diff -r 0434c999780c14204b60e51eed32d2d0c5c53401 -r 75b0af8a0a2b26a683d51331f6d69088ef18501a _pytest/monkeypatch.py --- a/_pytest/monkeypatch.py +++ b/_pytest/monkeypatch.py @@ -1,6 +1,7 @@ """ monkeypatching and mocking functionality. """ import os, sys +from py.builtin import _basestring def pytest_funcarg__monkeypatch(request): """The returned ``monkeypatch`` funcarg provides these @@ -28,7 +29,7 @@ def derive_importpath(import_path): import pytest - if not isinstance(import_path, str) or "." not in import_path: + if not isinstance(import_path, basestring) or "." not in import_path: raise TypeError("must be absolute import path string, not %r" % (import_path,)) rest = [] @@ -85,7 +86,7 @@ import inspect if value is notset: - if not isinstance(target, str): + if not isinstance(target, _basestring): raise TypeError("use setattr(target, name, value) or " "setattr(target, value) with target being a dotted " "import string") @@ -115,7 +116,7 @@ """ __tracebackhide__ = True if name is notset: - if not isinstance(target, str): + if not isinstance(target, basestring): raise TypeError("use delattr(target, name) or " "delattr(target) with target being a dotted " "import string") diff -r 0434c999780c14204b60e51eed32d2d0c5c53401 -r 75b0af8a0a2b26a683d51331f6d69088ef18501a testing/test_monkeypatch.py --- a/testing/test_monkeypatch.py +++ b/testing/test_monkeypatch.py @@ -45,6 +45,12 @@ import _pytest assert _pytest.config.Config == 42 + def test_unicode_string(self, monkeypatch): + monkeypatch.setattr(u"_pytest.config.Config", 42) + import _pytest + assert _pytest.config.Config == 42 + monkeypatch.delattr(u"_pytest.config.Config") + def test_wrong_target(self, monkeypatch): pytest.raises(TypeError, lambda: monkeypatch.setattr(None, None)) Repository URL: https://bitbucket.org/hpk42/pytest/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. _______________________________________________ pytest-commit mailing list pytest-commit@python.org https://mail.python.org/mailman/listinfo/pytest-commit