Skip to content

Commit

Permalink
2.1.0a4 - Fix bug in automatic resource registration.
Browse files Browse the repository at this point in the history
Reversed the lie I told myself in the test suite as well.
  • Loading branch information
ralphbean committed May 27, 2012
1 parent c822b2a commit efcd517
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def get_description(fname='README.rst'):

setup(
name='tw2.core',
version='2.1.0a3',
version='2.1.0a4',
description="Web widget creation toolkit based on TurboGears widgets",
long_description = get_description(),
install_requires=requires,
Expand Down
7 changes: 3 additions & 4 deletions tests/test_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ def test_find_charset():


class TestResourcesMisc(TestCase):
real_modname = 'nose.importer'

def testJSSymbol(self):
"""
Expand Down Expand Up @@ -319,19 +318,19 @@ def testLinkHash(self):

def testAutoModname(self):
l = twr.Link(filename="somefile")
eq_(l.modname, self.real_modname)
eq_(l.modname, __name__)

def testAutoModnameReqPrep(self):
l = twr.Link(filename="somefile")
l = l.req()
l.prepare()
eq_(l.modname, self.real_modname)
eq_(l.modname, __name__)

def testAutoModnameInject(self):
l = twr.Link(filename="somefile")
l.inject()
local = tw2.core.core.request_local()
eq_(local['resources'][0].modname, self.real_modname)
eq_(local['resources'][0].modname, __name__)

def testDirLink(self):
dl = twr.DirLink(modname="tw2.core", filename="somefile")
Expand Down
6 changes: 3 additions & 3 deletions tw2/core/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ def guess_modname(cls):
@classmethod
def post_define(cls):

if not cls.modname:
cls.modname = cls.guess_modname()

if not cls.no_inject:
if getattr(cls, 'filename', None) and \
type(cls.filename) != property:

if not cls.modname:
cls.modname = cls.guess_modname()

md.register_resource(
cls.modname or '__anon__', cls.filename, cls.whole_dir
)
Expand Down

0 comments on commit efcd517

Please sign in to comment.