Broken test in config

Bug #503731 reported by Fernando Perez
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
IPython
Fix Committed
High
Fernando Perez

Bug Description

Brian, another one I need a hand with :)

I'm not sure if this one was ever supposed to pass or not... If you know what's going on, I can try to fix it, but I'm not sure if you meant for config files to be able to state

Foo.bar = 1

without previously declaring Foo first. The code in loader.py runs

        namespace = dict(load_subconfig=load_subconfig, get_config=get_config)
        execfile(self.full_filename, namespace)

and since namespace is just a plain python dict with no 'magical' self-creating of capitalized attributes, that code will not work. I'm not sure what the resolution should be here though...

Thanks!

maqroll[scripts]> ./iptest -v IPython.config
/usr/lib/pymodules/python2.6/foolscap/banana.py:2: DeprecationWarning: the sets module is deprecated
  import struct, sets, time
........E
======================================================================
ERROR: test_basic (IPython.config.tests.test_loader.TestPyFileCL)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/fperez/usr/lib/python2.6/site-packages/IPython/config/tests/test_loader.py", line 56, in test_basic
    config = cl.load_config()
  File "/home/fperez/usr/lib/python2.6/site-packages/IPython/config/loader.py", line 246, in load_config
    self._read_file_as_dict()
  File "/home/fperez/usr/lib/python2.6/site-packages/IPython/config/loader.py", line 280, in _read_file_as_dict
    execfile(self.full_filename, namespace)
  File "/tmp/tmpqsXh5V.py", line 4, in <module>
    Foo.Bar.value = 10
NameError: name 'Foo' is not defined

----------------------------------------------------------------------
Ran 9 tests in 0.013s

FAILED (errors=1)

Related branches

Revision history for this message
Brian Granger (ellisonbg) wrote : Re: [Bug 503731] [NEW] Broken test in config
Download full text (4.3 KiB)

On Wed, Jan 6, 2010 at 1:53 AM, Fernando Perez <email address hidden> wrote:
> Public bug reported:
>
> Brian, another one I need a hand with :)
>
> I'm not sure if this one was ever supposed to pass or not... If you know
> what's going on, I can try to fix it, but I'm not sure if you meant for
> config files to be able to state
>
> Foo.bar = 1

No, this should not work. Instead it should be something like config.Foo.bar.

But where did you find this code? All the default config files should
have been updated to the
new convention. The fix will be to simply create an appropriate
config instance to set Foo.bar on.

Brian

> without previously declaring Foo first.  The code in loader.py runs
>
>        namespace = dict(load_subconfig=load_subconfig, get_config=get_config)
>        execfile(self.full_filename, namespace)
>
> and since namespace is just a  plain python dict with no 'magical' self-
> creating of capitalized attributes, that code will not work.  I'm not
> sure what the resolution should be here though...
>
> Thanks!
>
> maqroll[scripts]> ./iptest -v IPython.config
> /usr/lib/pymodules/python2.6/foolscap/banana.py:2: DeprecationWarning: the sets module is deprecated
>  import struct, sets, time
> ........E
> ======================================================================
> ERROR: test_basic (IPython.config.tests.test_loader.TestPyFileCL)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>  File "/home/fperez/usr/lib/python2.6/site-packages/IPython/config/tests/test_loader.py", line 56, in test_basic
>    config = cl.load_config()
>  File "/home/fperez/usr/lib/python2.6/site-packages/IPython/config/loader.py", line 246, in load_config
>    self._read_file_as_dict()
>  File "/home/fperez/usr/lib/python2.6/site-packages/IPython/config/loader.py", line 280, in _read_file_as_dict
>    execfile(self.full_filename, namespace)
>  File "/tmp/tmpqsXh5V.py", line 4, in <module>
>    Foo.Bar.value = 10
> NameError: name 'Foo' is not defined
>
> ----------------------------------------------------------------------
> Ran 9 tests in 0.013s
>
> FAILED (errors=1)
>
> ** Affects: ipython
>     Importance: High
>         Status: Confirmed
>
> --
> Broken test in config
> https://bugs.launchpad.net/bugs/503731
> You received this bug notification because you are a member of IPython
> Developers, which is subscribed to IPython.
>
> Status in IPython - Enhanced Interactive Python: Confirmed
>
> Bug description:
> Brian, another one I need a hand with :)
>
> I'm not sure if this one was ever supposed to pass or not... If you know what's going on, I can try to fix it, but I'm not sure if you meant for config files to be able to state
>
> Foo.bar = 1
>
> without previously declaring Foo first.  The code in loader.py runs
>
>        namespace = dict(load_subconfig=load_subconfig, get_config=get_config)
>        execfile(self.full_filename, namespace)
>
> and since namespace is just a  plain python dict with no 'magical' self-creating of capitalized attributes, that code will not work.  I'm not sure what the resolution should be here though...
>
> Thanks!
>
> maqroll[scripts]> ./iptest -v ...

Read more...

Revision history for this message
Fernando Perez (fdo.perez) wrote :

Hey,

On Wed, Jan 6, 2010 at 6:06 AM, Brian Granger <email address hidden> wrote:
> No, this should not work.  Instead it should be something like
> config.Foo.bar.
>
> But where did you find this code?  All the default config files should
> have been updated to the
> new convention.  The fix will be to simply create an appropriate
> config instance to set Foo.bar on.
>

The failure was in:

ERROR: test_basic (IPython.config.tests.test_loader.TestPyFileCL)
----------------------------------------------------------------------
Traceback (most recent call last):
 File "/home/fperez/usr/lib/python2.6/site-packages/IPython/config/tests/test_loader.py",
line 56, in test_basic
   config = cl.load_config()

That config text is a bit of inline code in that test file
(test_loader.py). Prepending 'config.Foo...' doesn't seem to help
though, there's no get_config() call at the top.

Revision history for this message
Brian Granger (ellisonbg) wrote :

In line 39, the pyfile should be something like this:

pyfile = """
c = get_config()
a = 10
b = 20
c.Foo.Bar.value = 10
c.Foo.Bam.value = range(10)
c.D.C.value = 'hi there'
"""

Basically, pyfile should be a valid config file. It looks like I
never updated that test since the change.

Let me know if that helps or if there is still a problem.

Brian

> The failure was in:
>
> ERROR: test_basic (IPython.config.tests.test_loader.TestPyFileCL)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>  File "/home/fperez/usr/lib/python2.6/site-packages/IPython/config/tests/test_loader.py",
> line 56, in test_basic
>   config = cl.load_config()
>
>
> That config text is a bit of inline code in that test file
> (test_loader.py).  Prepending 'config.Foo...' doesn't seem to help
> though, there's no get_config() call at the top.
>
> --
> Broken test in config
> https://bugs.launchpad.net/bugs/503731
> You received this bug notification because you are a member of IPython
> Developers, which is subscribed to IPython.
>
> Status in IPython - Enhanced Interactive Python: Confirmed
>
> Bug description:
> Brian, another one I need a hand with :)
>
> I'm not sure if this one was ever supposed to pass or not... If you know what's going on, I can try to fix it, but I'm not sure if you meant for config files to be able to state
>
> Foo.bar = 1
>
> without previously declaring Foo first.  The code in loader.py runs
>
>        namespace = dict(load_subconfig=load_subconfig, get_config=get_config)
>        execfile(self.full_filename, namespace)
>
> and since namespace is just a  plain python dict with no 'magical' self-creating of capitalized attributes, that code will not work.  I'm not sure what the resolution should be here though...
>
> Thanks!
>
> maqroll[scripts]> ./iptest -v IPython.config
> /usr/lib/pymodules/python2.6/foolscap/banana.py:2: DeprecationWarning: the sets module is deprecated
>  import struct, sets, time
> ........E
> ======================================================================
> ERROR: test_basic (IPython.config.tests.test_loader.TestPyFileCL)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>  File "/home/fperez/usr/lib/python2.6/site-packages/IPython/config/tests/test_loader.py", line 56, in test_basic
>    config = cl.load_config()
>  File "/home/fperez/usr/lib/python2.6/site-packages/IPython/config/loader.py", line 246, in load_config
>    self._read_file_as_dict()
>  File "/home/fperez/usr/lib/python2.6/site-packages/IPython/config/loader.py", line 280, in _read_file_as_dict
>    execfile(self.full_filename, namespace)
>  File "/tmp/tmpqsXh5V.py", line 4, in <module>
>    Foo.Bar.value = 10
> NameError: name 'Foo' is not defined
>
> ----------------------------------------------------------------------
> Ran 9 tests in 0.013s
>
> FAILED (errors=1)
>
>
>

--
Brian E. Granger, Ph.D.
Assistant Professor of Physics
Cal Poly State University, San Luis Obispo
<email address hidden>
<email address hidden>

Revision history for this message
Fernando Perez (fdo.perez) wrote :

On Wed, Jan 6, 2010 at 12:59 PM, Brian Granger <email address hidden> wrote:
> In line 39, the pyfile should be something like this:
>
> pyfile = """
> c = get_config()
> a = 10
> b = 20
> c.Foo.Bar.value = 10
> c.Foo.Bam.value = range(10)
> c.D.C.value = 'hi there'
> """
>
> Basically, pyfile should be a valid config file.  It looks like I
> never updated that test since the change.
>
> Let me know if that helps or if there is still a problem.

Almost! But you got me on the right track, thanks, all that was
missing was c. for a, b, c:

pyfile = """
c = get_config()
c.a = 10
c.b = 20
c.Foo.Bar.value = 10
c.Foo.Bam.value = range(10)
c.D.C.value = 'hi there'
"""

We're good now. Will commit the fix in a second, thanks a lot!

Changed in ipython:
assignee: nobody → Fernando Perez (fdo.perez)
status: Confirmed → Fix Committed
Revision history for this message
Fernando Perez (fdo.perez) wrote :

Fix committed in my trunk-dev branch, will be soon in trunk after review.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.