Following #2737 this error is now a name error
Merge pull request #2740 from jenshnielsen/rnameerror

Fix tests for rmagic (KeyError -> NameError).

Caused by #2737.