From bbcbd60ea4f6ce58cdc31088c0663e6766a30c10 2013-07-16 23:12:53 From: MinRK <benjaminrk@gmail.com> Date: 2013-07-16 23:12:53 Subject: [PATCH] test strip_encoding_cookie transformer --- diff --git a/IPython/core/tests/test_inputtransformer.py b/IPython/core/tests/test_inputtransformer.py index e578147..373aa5f 100644 --- a/IPython/core/tests/test_inputtransformer.py +++ b/IPython/core/tests/test_inputtransformer.py @@ -65,6 +65,13 @@ syntax = \ (' ',' '), # blank lines are kept intact ], + strip_encoding_cookie = + [ + ('# -*- encoding: utf-8 -*-', ''), + ('# coding: latin-1', ''), + ], + + # Tests for the escape transformer to leave normal code alone escaped_noesc = [ (' ', ' '), @@ -203,6 +210,20 @@ syntax_ml = \ ], ], + strip_encoding_cookie = + [ + [ + ('# -*- coding: utf-8 -*-', ''), + ('foo', 'foo'), + ], + [ + ('#!/usr/bin/env python', '#!/usr/bin/env python'), + ('# -*- coding: latin-1 -*-', ''), + # only the first-two lines + ('# -*- coding: latin-1 -*-', '# -*- coding: latin-1 -*-'), + ], + ], + multiline_datastructure_prompt = [ [('>>> a = [1,','a = [1,'), ('... 2]','2]'), @@ -291,6 +312,11 @@ def test_ipy_prompt(): for example in syntax_ml['ipy_prompt']: transform_checker(example, ipt.ipy_prompt) +def test_coding_cookie(): + tt.check_pairs(transform_and_reset(ipt.strip_encoding_cookie), syntax['strip_encoding_cookie']) + for example in syntax_ml['strip_encoding_cookie']: + transform_checker(example, ipt.strip_encoding_cookie) + def test_assemble_logical_lines(): tests = \ [ [(u"a = \\", None),