Permalink
Browse files

Tweak test for magic_cpaste.

  • Loading branch information...
1 parent 155b20c commit 15192a1f4cf1645b15b636d375bc7af798c96cf9 @takluyver committed Oct 26, 2011
Showing with 3 additions and 4 deletions.
  1. +3 −4 IPython/core/tests/test_magic.py
@@ -324,10 +324,9 @@ def check_cpaste(code, should_fail=False):
_ip.user_ns['code_ran'] = False
src = StringIO()
- try:
- src.encoding = None # IPython expects stdin to have an encoding attribute
- except Exception:
- pass # ...but it's a read-only attribute in Python 3
+ if not hasattr(src, 'encoding'):
+ # IPython expects stdin to have an encoding attribute
+ src.encoding = None
src.write('\n')
src.write(code)
src.write('\n--\n')

0 comments on commit 15192a1

Please sign in to comment.