* Ben Finney [2008-08-22 08:21 +0200]:
Tags: patch

On 22-Aug-2008, Nicolas Évrard wrote:
* Ben Finney [2008-08-22 01:25 +0200]:
On 21-Aug-2008, Nicolas Évrard wrote:
    % nosetests --cover-erase --with-coverage --cover-package=relatorio

And it shows the following table after the tests has runned:

    Name                               Stmts   Exec  Cover   Missing
    ----------------------------------------------------------------
relatorio 3 3 100% relatorio.reporting 78 0 0% 21-146
    relatorio.templates                   11      0     0%   21-39
    relatorio.templates.chart             48      0     0%   21-93
    relatorio.templates.opendocument     212      0     0%   21-331
    relatorio.templates.pdf               44      0     0%   21-86
    ----------------------------------------------------------------
TOTAL 396 3 0%

I believe python-coverage is behaving correctly in this case. Python doesn't care whether a module is actually a symlink on disk; different module files are different files. Indeed, modules should be implemented so that they work whether or not the filesystem supports symlinks. Python's namespace support makes this easy.

Well while developping I often replace the module in my $HOME/python by a symlink to the directory where I am working so I do not use the symlink to have code accessible through two different namespaces. So here's my setup:

    $PYTHONPATH=.:$HOME/python
    % ls $HOME/python
    relatorio -> wherever the developpment version is

I don't understand, then. Which of the above modules are duplicates, under your setup? Where are the actual files? What is symlinking to what?

Here is a patch for this issue, that fixes the problem I am encountering.

--
(°>  Nicolas Évrard
/ )  Liège - Belgique
^^
--- coverage.py	2008-08-25 08:46:53.000000000 +0200
+++ coverage.py.old	2008-08-25 08:46:24.000000000 +0200
@@ -534,7 +534,7 @@
                     if os.path.exists(g):
                         f = g
                         break
-            cf = os.path.normcase(os.path.realpath(os.path.abspath(f)))
+            cf = os.path.normcase(os.path.abspath(f))
             self.canonical_filename_cache[filename] = cf
         return self.canonical_filename_cache[filename]
 

Reply via email to