Ticket #1821 (closed defect: fixed)

Opened 2 months ago

Last modified 1 month ago

[PATCH] testutil guesses wrong module name

Reported by: ctrochalakis Assigned to: anonymous
Priority: normal Milestone: 1.0.x bugfix
Component: TurboGears Version: 1.0.4.4
Severity: normal Keywords: tests
Cc: dimitris@glezos.com, Felix.Schwarz

Description

When testutil wants to update the global configuration with test.cfg, it's trying to guess the module name (code line 37). It seems that the endswith('config') is a weak test for that purpose: It might match something completely irrelevant.

We use mercurial as our vcs. Mercurial happens to have a .hg/store/data/transifex/config/ dir in the .hg directory. if os.walk(pwd) returns that dir before the correct transifex/config dir the whole thing breaks causing tests to be completely unusable.

This is not always reproducible, it depends on the order os.walk returns directories.

# Override config of all applications with test.cfg
if os.path.exists(os.path.join(cwd, "test.cfg")):
    modulename = None
    for w in os.walk(cwd):
        if w[0].endswith("config"):
            config_dir = w[0].replace(cwd, "")[1:]
            modulename = "%s.app" % config_dir.replace(os.sep, ".")
            break
    update_config(configfile=os.path.join(cwd, "test.cfg"),
        modulename=modulename)

Attachments

cooperate_with_dot_directories (0.7 kB) - added by Felix.Schwarz on 05/21/08 04:49:53.
Patch was produced using Mercurial queues, so please apply with "patch -p1"

Change History

05/21/08 04:48:49 changed by Felix.Schwarz

  • summary changed from testutil guesses wrong module name to [PATCH] testutil guesses wrong module name.

I experienced the same issue today. I'm not sure how to really fix this (or even if we should bother fixing this 'the right way' given that TG2 will probably use a different mechanism) but I built a patch which fixes this issue that testutil gets invalid module names such as '.hg.store.data.transifex.config'.

Python module names must not start with '.' therefore I just exclude all directories with do start with a dot.

05/21/08 04:49:53 changed by Felix.Schwarz

  • attachment cooperate_with_dot_directories added.

Patch was produced using Mercurial queues, so please apply with "patch -p1"

05/21/08 04:59:57 changed by Felix.Schwarz

  • cc changed from dimitris@glezos.com to dimitris@glezos.com, Felix.Schwarz.

06/14/08 14:46:56 changed by chrisz

  • status changed from new to closed.
  • resolution set to fixed.

Fixed in r4741.