From 5eda96b779c136a64c25bad371dbd04c2b89d377 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Mon, 6 Dec 2010 15:39:06 -0500 Subject: [PATCH] added absolute paths for other static and template tests --- tests/test_base.py | 17 ++++++++++------- tests/test_static.py | 8 ++++++-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/tests/test_base.py b/tests/test_base.py index 82b1c02..47efba1 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -1,3 +1,4 @@ +import os from pecan import Pecan, expose, request, response, redirect from webtest import TestApp from formencode import Schema, validators @@ -100,18 +101,20 @@ class TestBase(object): class TestEngines(object): + template_path = os.path.join(os.path.dirname(__file__), 'templates') + def test_genshi(self): class RootController(object): @expose('genshi:genshi.html') def index(self, name='Jonathan'): return dict(name=name) - app = TestApp(Pecan(RootController(), template_path='tests/templates')) + app = TestApp(Pecan(RootController(), template_path=self.template_path)) r = app.get('/') assert r.status_int == 200 assert "

Hello, Jonathan!

" in r.body - app = TestApp(Pecan(RootController(), template_path='tests/templates')) + app = TestApp(Pecan(RootController(), template_path=self.template_path)) r = app.get('/index.html?name=World') assert r.status_int == 200 assert "

Hello, World!

" in r.body @@ -122,12 +125,12 @@ class TestEngines(object): def index(self, name='Jonathan'): return dict(name=name) - app = TestApp(Pecan(RootController(), template_path='tests/templates')) + app = TestApp(Pecan(RootController(), template_path=self.template_path)) r = app.get('/') assert r.status_int == 200 assert "

Hello, Jonathan!

" in r.body - app = TestApp(Pecan(RootController(), template_path='tests/templates')) + app = TestApp(Pecan(RootController(), template_path=self.template_path)) r = app.get('/index.html?name=World') assert r.status_int == 200 assert "

Hello, World!

" in r.body @@ -138,12 +141,12 @@ class TestEngines(object): def index(self, name='Jonathan'): return dict(name=name) - app = TestApp(Pecan(RootController(), template_path='tests/templates')) + app = TestApp(Pecan(RootController(), template_path=self.template_path)) r = app.get('/') assert r.status_int == 200 assert "

Hello, Jonathan!

" in r.body - app = TestApp(Pecan(RootController(), template_path='tests/templates')) + app = TestApp(Pecan(RootController(), template_path=self.template_path)) r = app.get('/index.html?name=World') assert r.status_int == 200 assert "

Hello, World!

" in r.body @@ -253,4 +256,4 @@ class TestEngines(object): app = TestApp(Pecan(RootController())) r = app.get('/test/1/2/3/4') assert r.status_int == 200 - assert r.body == 'it worked' \ No newline at end of file + assert r.body == 'it worked' diff --git a/tests/test_static.py b/tests/test_static.py index ab07865..ea2b049 100644 --- a/tests/test_static.py +++ b/tests/test_static.py @@ -1,3 +1,4 @@ +import os from pecan import expose, make_app from webtest import TestApp @@ -10,7 +11,10 @@ class TestStatic(object): return 'Hello, World!' # make sure Cascade is working properly - app = TestApp(make_app(RootController(), static_root='tests/static')) + text = os.path.join(os.path.dirname(__file__), 'static/text.txt') + static_root = os.path.join(os.path.dirname(__file__), 'static') + + app = TestApp(make_app(RootController(), static_root=static_root)) response = app.get('/index.html') assert response.status_int == 200 assert response.body == 'Hello, World!' @@ -18,4 +22,4 @@ class TestStatic(object): # get a static resource response = app.get('/text.txt') assert response.status_int == 200 - assert response.body == open('tests/static/text.txt', 'rb').read() \ No newline at end of file + assert response.body == open(text, 'rb').read()