Ticket #1821 (closed defect: fixed)
[PATCH] testutil guesses wrong module name
| Reported by: | ctrochalakis | Owned by: | anonymous |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.0.x bugfix |
| Component: | TurboGears | Version: | 1.0.4.4 |
| Severity: | normal | Keywords: | tests |
| Cc: | dimitris@…, 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
Change History
comment:1 Changed 4 years ago by Felix.Schwarz
- Summary changed from testutil guesses wrong module name to [PATCH] testutil guesses wrong module name
Changed 4 years ago by Felix.Schwarz
-
attachment
cooperate_with_dot_directories
added
Patch was produced using Mercurial queues, so please apply with "patch -p1"
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.