From bb672fe3c2e2a90fa149ba575e36d45c7a4271f7 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sat, 17 Jan 2009 18:59:53 +0000 Subject: - Allow the ``repoze.bfg.view.static`` helper to be passed a relative ``root_path`` name; it will be considered relative to the file in which it was called. --- repoze/bfg/tests/test_view.py | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'repoze/bfg/tests') diff --git a/repoze/bfg/tests/test_view.py b/repoze/bfg/tests/test_view.py index 53c0248ed..ca1037a67 100644 --- a/repoze/bfg/tests/test_view.py +++ b/repoze/bfg/tests/test_view.py @@ -432,24 +432,34 @@ class TestStaticView(unittest.TestCase, BaseTest): from repoze.bfg.view import static return static - def _getHere(self): + def _makeOne(self, path): + return self._getTargetClass()(path) + + def test_abspath(self): import os - return os.path.dirname(__file__) + path = os.path.dirname(__file__) + view = self._makeOne(path) + context = DummyContext() + request = DummyRequest() + request.subpath = ['__init__.py'] + request.environ = self._makeEnviron() + response = view(context, request) + self.assertEqual(request.copied, True) + self.assertEqual(response.directory, path) - def _makeOne(self): - here = self._getHere() - return self._getTargetClass()(here) - - def test_it(self): - view = self._makeOne() + def test_relpath(self): + import os + path = 'fixtures' + view = self._makeOne(path) context = DummyContext() request = DummyRequest() request.subpath = ['__init__.py'] request.environ = self._makeEnviron() response = view(context, request) self.assertEqual(request.copied, True) - here = self._getHere() - self.assertEqual(response.directory, here) + here = os.path.abspath(os.path.dirname(__file__)) + abspath = os.path.join(here, 'fixtures') + self.assertEqual(response.directory, abspath) class TestBFGViewDecorator(unittest.TestCase): def setUp(self): -- cgit v1.2.3