Commit f9a5b3d2 by Chris Jerdonek

Tests now working after making tests directory a sub-package.

parent 15fbaa53
......@@ -8,10 +8,14 @@ Provides test-related code that can be used by all tests.
import os
import examples
import pystache
DATA_DIR = 'tests/data'
_TESTS_DIR = os.path.dirname(pystache.tests.__file__)
DATA_DIR = os.path.join(_TESTS_DIR, 'data') # i.e. 'pystache/tests/data'.
EXAMPLES_DIR = os.path.dirname(examples.__file__)
SPEC_TEST_DIR = os.path.join(os.path.dirname(pystache.__file__), '..', 'ext', 'spec', 'specs')
def get_data_path(file_name):
......
......@@ -11,7 +11,7 @@ import unittest
from pystache.context import _NOT_FOUND
from pystache.context import _get_value
from pystache.context import Context
from tests.common import AssertIsMixin
from pystache.tests.common import AssertIsMixin
class SimpleObject(object):
......
......@@ -12,8 +12,8 @@ from examples.unicode_output import UnicodeOutput
from examples.unicode_input import UnicodeInput
from examples.nested_context import NestedContext
from pystache import Renderer
from tests.common import EXAMPLES_DIR
from tests.common import AssertStringMixin
from pystache.tests.common import EXAMPLES_DIR
from pystache.tests.common import AssertStringMixin
class TestView(unittest.TestCase, AssertStringMixin):
......
......@@ -9,14 +9,11 @@ import os
import sys
import unittest
from tests.common import AssertStringMixin
from pystache.tests.common import AssertStringMixin, DATA_DIR
from pystache import defaults
from pystache.loader import Loader
DATA_DIR = 'tests/data'
class LoaderTests(unittest.TestCase, AssertStringMixin):
def test_init__extension(self):
......
# encoding: utf-8
"""
Contains locator.py unit tests.
Unit tests for locator.py.
"""
......@@ -14,7 +14,7 @@ import unittest
from pystache.loader import Loader as Reader
from pystache.locator import Locator
from tests.common import DATA_DIR
from pystache.tests.common import DATA_DIR
from data.views import SayHello
......
......@@ -11,7 +11,7 @@ import unittest
from pystache.context import Context
from pystache.parser import ParsingError
from pystache.renderengine import RenderEngine
from tests.common import AssertStringMixin
from pystache.tests.common import AssertStringMixin
class RenderEngineTestCase(unittest.TestCase):
......
......@@ -15,9 +15,9 @@ from pystache import Renderer
from pystache import TemplateSpec
from pystache.loader import Loader
from tests.common import get_data_path
from tests.common import AssertStringMixin
from tests.data.views import SayHello
from pystache.tests.common import get_data_path
from pystache.tests.common import AssertStringMixin
from pystache.tests.data.views import SayHello
class RendererInitTestCase(unittest.TestCase):
......
......@@ -8,8 +8,8 @@ from examples.lambdas import Lambdas
from examples.template_partial import TemplatePartial
from examples.simple import Simple
from tests.common import EXAMPLES_DIR
from tests.common import AssertStringMixin
from pystache.tests.common import EXAMPLES_DIR
from pystache.tests.common import AssertStringMixin
class TestSimple(unittest.TestCase, AssertStringMixin):
......
......@@ -24,12 +24,16 @@ import glob
import os.path
import unittest
import pystache
from pystache.renderer import Renderer
from tests.common import AssertStringMixin
from pystache.tests.common import AssertStringMixin, SPEC_TEST_DIR
root_path = os.path.join(os.path.dirname(__file__), '..', 'ext', 'spec', 'specs')
spec_paths = glob.glob(os.path.join(root_path, '*.json'))
spec_paths = glob.glob(os.path.join(SPEC_TEST_DIR, '*.json'))
if len(spec_paths) == 0:
raise Exception("""Spec tests not found in: %s
Consult the README file on how to add the spec tests.""" % repr(SPEC_TEST_DIR))
# TODO: give this a name better than MustacheSpec.
......@@ -92,6 +96,7 @@ def buildTest(testData, spec_filename):
return test
for spec_path in spec_paths:
file_name = os.path.basename(spec_path)
......
......@@ -19,12 +19,12 @@ from pystache import TemplateSpec
from pystache.locator import Locator
from pystache.loader import Loader
from pystache.spec_loader import SpecLoader
from tests.common import DATA_DIR
from tests.common import EXAMPLES_DIR
from tests.common import AssertIsMixin
from tests.common import AssertStringMixin
from tests.data.views import SampleView
from tests.data.views import NonAscii
from pystache.tests.common import DATA_DIR
from pystache.tests.common import EXAMPLES_DIR
from pystache.tests.common import AssertIsMixin
from pystache.tests.common import AssertStringMixin
from pystache.tests.data.views import SampleView
from pystache.tests.data.views import NonAscii
class Thing(object):
......@@ -46,7 +46,8 @@ class ViewTestCase(unittest.TestCase, AssertStringMixin):
self.assertRaises(IOError, renderer.render, view)
view.template_rel_directory = "../examples"
# TODO: change this test to remove the following brittle line.
view.template_rel_directory = "../../examples"
actual = renderer.render(view)
self.assertEquals(actual, "No tags...")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment