Last active
August 29, 2015 14:13
-
-
Save rach/a376ea53379b5ed37841 to your computer and use it in GitHub Desktop.
Fixture to check if resolve
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@pytest.fixture | |
def url_checker(): | |
from pyramid.scripts.pviews import PViewsCommand | |
from pyramid.request import Request | |
from pyramid.paster import bootstrap | |
def view_match(url): | |
pviews = PViewsCommand([None, os.path.join(here, '../', 'development.ini'), url], | |
quiet=True) | |
config_uri = pviews.args[0] | |
url = pviews.args[1] | |
request = Request.blank(url) | |
env = bootstrap(config_uri, request=request) | |
view = pviews._find_view(request) | |
result = True | |
if view is None: | |
result = False | |
env['closer']() | |
return result | |
return view_match |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment