MCPcopy Create free account
hub / github.com/ipython/ipython / check_ns

Method check_ns

IPython/core/tests/test_inputsplitter.py:353–367  ·  view source on GitHub ↗

Validate that the given input lines produce the resulting namespace. Note: the input lines are given exactly as they would be typed in an auto-indenting environment, as mini_interactive_loop above already does auto-indenting and prepends spaces to the input.

(self, lines, ns)

Source from the content-addressed store, hash-verified

351 """Tests for an interactive loop like a python shell.
352 """
353 def check_ns(self, lines, ns):
354 """Validate that the given input lines produce the resulting namespace.
355
356 Note: the input lines are given exactly as they would be typed in an
357 auto-indenting environment, as mini_interactive_loop above already does
358 auto-indenting and prepends spaces to the input.
359 """
360 src = mini_interactive_loop(pseudo_input(lines))
361 test_ns = {}
362 exec(src, test_ns)
363 # We can't check that the provided ns is identical to the test_ns,
364 # because Python fills test_ns with extra keys (copyright, etc). But
365 # we can check that the given dict is *contained* in test_ns
366 for k,v in ns.items():
367 self.assertEqual(test_ns[k], v)
368
369 def test_simple(self):
370 self.check_ns(['x=1'], dict(x=1))

Callers 5

test_simpleMethod · 0.95
test_simple2Method · 0.95
test_xyMethod · 0.95
test_abcMethod · 0.95
test_multiMethod · 0.95

Calls 2

mini_interactive_loopFunction · 0.85
pseudo_inputFunction · 0.85

Tested by

no test coverage detected