Skip to content

Instantly share code, notes, and snippets.

@rach
Last active August 29, 2015 14:13
Show Gist options
  • Save rach/a376ea53379b5ed37841 to your computer and use it in GitHub Desktop.
Save rach/a376ea53379b5ed37841 to your computer and use it in GitHub Desktop.
Fixture to check if resolve
@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