From 8448fd0360fcccbea298367e2d84701149551716 2012-08-14 16:44:05 From: Thomas Kluyver Date: 2012-08-14 16:44:05 Subject: [PATCH] Add failing test for variable expansion with self (reopened issue #1878). --- diff --git a/IPython/core/tests/test_interactiveshell.py b/IPython/core/tests/test_interactiveshell.py index fe01c40..dff0e22 100644 --- a/IPython/core/tests/test_interactiveshell.py +++ b/IPython/core/tests/test_interactiveshell.py @@ -258,6 +258,18 @@ class InteractiveShellTestCase(unittest.TestCase): ip.run_cell('makemacro()') nt.assert_in('macro_var_expand_locals', ip.user_ns) + def test_var_expand_self(self): + """Test variable expansion with the name 'self', which was failing. + + See https://github.com/ipython/ipython/issues/1878#issuecomment-7698218 + """ + ip.run_cell('class cTest:\n' + ' classvar="see me"\n' + ' def test(self):\n' + ' res = !echo Variable: {self.classvar}\n' + ' return res\n') + nt.assert_in('see me', ip.user_ns['cTest']().test()) + def test_bad_var_expand(self): """var_expand on invalid formats shouldn't raise""" # SyntaxError