general03 / flask-autoindex

Generates index page like mod_autoindex
https://flask-autoindex.readthedocs.io
MIT License
114 stars 34 forks source link

Problems with flask 0.10.1 #12

Closed pcpa closed 11 years ago

pcpa commented 11 years ago

Tests fail with this pattern:

$ PYTHONPATH=$PWD/build/lib/flaskext:$PYTHONPATH python tests/__init__.py
...............EEEEEEE
======================================================================
ERROR: test_autoindex (__main__.ApplicationTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/__init__.py", line 139, in setUp
    def autoindex(path='.'):
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1013, in decorator
    self.add_url_rule(rule, endpoint, f, **options)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 62, in wrapper_func
    return f(self, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 984, in add_url_rule
    'existing endpoint function: %s' % endpoint)
AssertionError: View function mapping is overwriting an existing endpoint function: autoindex

But this is the only failure pattern.

pcpa commented 11 years ago

I made a bug report at https://bugzilla.redhat.com/show_bug.cgi?id=995716 with a link to a python-flask correction to most of this problem. My package, sagemath, that uses python-flask-autoindex works again if using the first chunk of https://github.com/mitsuhiko/flask/commit/44e39ab0 (the second chunk is already applied in the fedora package), but the tests for python-flask-autoindex still fail as initially reported.

I prefer to have it working instead of disabling %check, as currently python-flask-autoindex is FTBFS in fedora in bug report https://bugzilla.redhat.com/show_bug.cgi?id=992891

sebastinas commented 11 years ago

I got a little bit further by specifying an endpoint explicitly:

diff --git a/tests/__init__.py b/tests/__init__.py
index 8e542c2..613c640 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -135,8 +135,8 @@ class ApplicationTestCase(unittest.TestCase):
         self.idx = AutoIndex(self.app, browse_root, add_url_rules=True)
         self.idx2 = AutoIndex(self.app2,
                               silk_options={'silk_path': '/myicons'})
-        @self.app2.route('/')
-        @self.app2.route('/<path:path>')
+        @self.app2.route('/', endpoint="autoindex_endpoint")
+        @self.app2.route('/<path:path>', endpoint="autoindex_endpoint")
         def autoindex(path='.'):
             return self.idx2.render_autoindex(path, browse_root)

However, it later fails with

======================================================================
FAIL: test_autoindex (tests.ApplicationTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/sebastian/development/flask-autoindex/tests/__init__.py", line 170, in test_autoindex
    assert '__init__.py' in rv.data
AssertionError

and indeed, a simple

import os.path
from flask import Flask
from flask_autoindex import AutoIndex

app = Flask("foo")
idx = AutoIndex(app, add_url_rules=False)

@app.route('/')
@app.route('/<path:path>')
def show_lala(path='.'):
    return idx.render_autoindex(path, os.path.curdir)

app.run()

fails with an internal server error.

sublee commented 11 years ago

Sorry guys, I was late. I just fixed the test failure at 5e920c5c7ea675f7cae2f6e83b44209136f9b68d.

pcpa commented 11 years ago

I confirm the problem has been corrected. I will first make a python-flask-autoindex-0.4.1 update for fedora rawhide to close the FTBFS bug, then later will try to update to 0.5. Both 0.4.1 and 0.5 needs a minor edit in the commit correcting the problem.